Re: [Dev-C++] Adding and creating my own Lib files to Project
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Elizabeth B. <sog...@ya...> - 2002-08-26 22:29:56
|
Carlos =?iso-8859-1?Q?Garc=EDa?= del Monte <cg...@wo...> writes: > I have a couple of files: file.h and file.cpp which I want add to a > project, but which I'll want add to other projects, too. So I think > make a library file, libfile.a. I compile in command line g++ -c > file.cpp Then I do ar -r libfile.a file.o Then ar -s libfile.a I copy > it to c:\dev-cpp\lib\ I put in options (either project if it is > organized as project or compiler if simply mainfile.cpp #include > "file.cpp") -lfile, or -llibfile or -libfile or -lfile.a or > -llibfile.a, but depending on what I use I get or it does not find it > or undefined references. It happens the same if I leave libfile in the > same directory than the rest of the project (one single more file, > mainfile.cpp). > > What's my error? I mistake binutil? (ar -s = ranlib) It would be -lfile as the linker inserts 'lib' and adds on '.a'. You'd need to add in the library directory C:\dev-cpp\lib, however, for the linker to find it. For example, g++ -o test test.cpp -LC:\dev-cpp\lib -lfile The -L says to look in C:\dev-cpp\lib for the library file "libfile.a". If the library file is in the same directory, you could use -L. . Elizabeth |