Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sylvaincote

macrumors newbie
Original poster
Aug 25, 2008
2
0
Hello,

I am having difficulty linking using make created by Eclipse CDT.

My setup is the following:

- Mac Intel Code 2 Duo
- OS X 10.5.4 (fully patched)
- XCode 3.1
- Eclipse 3.4 (Ganymede) CDT
- Darwin ports 1.6.0
- cppunit 1.12.1

So cppunit libraries are located in /opt/local/lib/
and the header files are located in /opt/local/include

here is the result on the make session

**** Build of configuration Debug for project mycpptest ****

make all
Building file: ../src/main.cpp
Invoking: GCC C++ Compiler
g++ -I/opt/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o"src/main.o" "../src/main.cpp"
Finished building: ../src/main.cpp

Building target: mycpptest
Invoking: MacOS X C++ Linker
g++ -L/opt/local/lib -o "mycpptest" ./src/main.o -llibcppunit.a
ld: library not found for -llibcppunit.a
collect2: ld returned 1 exit status
make: *** [mycpptest] Error 1

The file libcppunit.a is really located in /opt/local/lib, I have verified.

I have tried multiple combinasons with the -L and -l parameters
with no success

For some reasons, the linker does not seems to like the library ???

Any suggestions ...

Thanks

Sylvain

PS: To validate the code and library I have created a project using XCode
and the file compile, link and run correctly.
 

kpua

macrumors 6502
Jul 25, 2006
294
0
First, try just -lcppunit. The linker usually adds the 'lib' prefix and any suffixes itself and is confused since you're giving it the entire library name.

If that doesn't work, IIRC, .a static libraries can simply be passed in as another linking unit. So, instead of using -l, just add /opt/local/lib/libcppunit.a as one of the parameters.
 

anonymousX1911

macrumors newbie
Jun 23, 2010
1
0
Thanks

For me the second option works:
specifying with -L and -l flags did not work.

just adding /usr/local/lib/foo.a as parameter worked:
g++ test.cpp /usr/local/lib/foo.a

:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.