Click here to Skip to main content
14,297,435 members
Rate this:
Please Sign up or sign in to vote.
See more:
How do you access a Library in C using notepad in windows? Thank you.

Changed title to "access library with notepad" which is more appropriate (from "create library with notepad").
Updated 11-Apr-11 18:03pm
Sergey Alexandrovich Kryukov 11-Apr-11 22:51pm
What that supposed to mean?
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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++?
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.
Sergey Alexandrovich Kryukov 11-Apr-11 23:38pm
Only don't use notepad, do yourself a fair, use some real editor. Notepad++ or something.
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.
Albert Holguin 11-Apr-11 23:38pm
thanks, great compliments coming from you sa! :D
Ozer Karaagac 11-Apr-11 23:53pm
Complete explanation. My 5.
Albert Holguin 11-Apr-11 23:54pm
thanks ozer, :)
RaviRanjanKr 12-Apr-11 0:05am
Nice Answer! My 5 :)
Albert Holguin 12-Apr-11 0:07am
thanks :)

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100