Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
4.25/5 (4 votes)
See more:
How do you access a Library in C using notepad in windows? Thank you.
DS

[EDIT]
Changed title to "access library with notepad" which is more appropriate (from "create library with notepad").
[/EDIT]
Posted
Updated 11-Apr-11 18:03pm
v3
Comments
Sergey Alexandrovich Kryukov 11-Apr-11 22:51pm    
What that supposed to mean?
--SA
Member 7766180 11-Apr-11 23:04pm    
I'm using notepad to write my program and i have libraries that I have to add. winpcap.lib and pcap.h in particular. Do I create a directory and place them in? and if so where and how? Like I said I am totally new to this. Any help appreciated thanks.

1 solution

If you're including a library in your source code, you must include the header in your source code (wherever you happen to use it) simply using a #include <pcap.h> if pcap.h is in a "default" directory or use #include "pcap.h" if its in the same directory as the file you're writing, or specify the whole directory path using #include "..\\winpcap\\pcap.h".

Now all I've talked about has been in reference to adding the library header to your project for compilation. Next step is adding the .lib file for linking. If you're using an IDE, this is simply added to the list of dependencies, or you can use a #pragma comment(lib, "winpcap.lib") statement in one of your header files.

By doing this, you're creating a dependency to a DLL, so you'll probably need to have the DLL in the same directory as your executable for everything to function correctly.

What compiler are you using? I imagine gcc or g++?
 
Share this answer
 
Comments
Member 7766180 11-Apr-11 23:35pm    
Thank You, Thank You so much! I have Visual Studio 2010, but its just too much at this point. I'm just learning C and I really like the simplicity of notepad. Any good websites on learning tis with notepad? I am using the Borland C++ 5.5 Free compiler. Once again, Thank You.
DS
Sergey Alexandrovich Kryukov 11-Apr-11 23:38pm    
Only don't use notepad, do yourself a fair, use some real editor. Notepad++ or something.
--SA
Albert Holguin 11-Apr-11 23:44pm    
I agree with sa... notepad is not a good editor, you'll really be missing out on features that make some things easy, like keyword (or syntax) highlighting and auto-indentation, little things like that make a world of difference for efficiency. You know you can even use the studio editor and you can still compile outside of it (to at least take advantage of the editor). I really haven't seen any articles on linking libraries in an all text environment, but i'll keep an eye out for you. BTW, as sa eluded to below, the compilers have command line options for including dependencies from there.
Sergey Alexandrovich Kryukov 11-Apr-11 23:36pm    
Good directions, my 5 for sure. It leaves for command-line compiler use, that's why you asked what is it.
--SA
Albert Holguin 11-Apr-11 23:38pm    
thanks, great compliments coming from you sa! :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900