Re: [Dev-C++] How to include my own Lib files
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Elizabeth B. <sog...@ya...> - 2002-08-26 04:12:25
|
"Napoleon Ahiable" <nah...@so...> writes: > Hello, > I have a directory C:\CppLab\MyLib which contains my Library files. I've = > been trying to include files from this directory in a program without = > success. I have entered the path under \Tools\Compiler = > Options\Directories\Include. But When I compile the program I get the = > linker error: > > //C/CppLab/Winnie/main.cpp:21: undefined reference to = > `Win::ClassMaker::ClassMaker(char const *, HINSTANCE__ *)' > //C/CppLab/Winnie/main.cpp:23: undefined reference to = > `Win::Maker::Maker(char const *, HINSTANCE__ *)' > //C/CppLab/Winnie/main.cpp:25: undefined reference to = > `Win::Maker::Create(Win::Controller &, char const *)' > > When I copy all the files into the same directory I get no errors. > What am I doing wrong ? I'm unable to check this one out at the moment but from what I gather, the "Options\Directories\Include" refer to include files (such as #include <win/winmaker.hpp>) and not the library files. If there is such an option as "Options\Directories\Libraries", try that with the library directories. Include files are part of the compiling stage, and as such they are needed by gcc (not the linker). The normal gcc command line option for this is -I, so if, say, you have certain include files in C:\dev\include, then the command line would look like this gcc -c x.c -IC:\dev\include This would look for include files in C:\dev\include (and any that are not resolved there would then go to the other, standard locations). For linking, though, one tells the linker (which may be called internally by GCC but the option is the same) where the library files with -L. If libXXXXX.a is in C:\dev\lib, then the command line would look something like (using gcc to do the linking): gcc -o testApplication.exe x.o -LC:\dev\lib -lXXXXX Note that the order is significant in linking (left to right). Dev-C++ does this automatically when it builds the makefile but it helps to understand what's going on under-the-hood. hth, Elizabeth |