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

Wnt2bsleepin

macrumors newbie
Original poster
Oct 12, 2011
15
0
I am trying to link my simple program to cpp-netlib. I downloaded and extracted the distribution, then ran the make file. It seems to find the header files fine, but it cannot find the libraries.

Here is my command that I am running to compile.

Code:
g++ Test.cpp -o Test -I/usr/local/cpp-netlib-0.10.1/  -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-client-connections.a -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-server-parsers.a -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-uri.a

However, it is saying the libraries are not found.

Code:
ld: library not found for -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-client-connections.a
collect2: ld returned 1 exit status

Cross posted over at DreamInCode. Any help is much appreciated.
 
Code:
g++ Test.cpp -o Test -I/usr/local/cpp-netlib-0.10.1/  -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-client-connections.a -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-server-parsers.a -l/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-uri.a

You are not using -l correctly here. The -l option instructs gcc to take the supplied argument, prepend it with "lib" and append ".a", and then traverse the Libraries search paths looking for a corresponding object file to link to. In your case, gcc is literally taking "/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-client-connections.a" and searching for "lib/usr/local/cpp-netlib-0.10.1/build/libs/network/src/libcppnetlib-client-connections.a.a". Clearly its not going to find anything to link against.

Either specify the full path to the object code you wish to statically link in without the -l flag, or include a search path with -L and use -l as such:

Code:
g++ Test.cpp -o Test -I/usr/local/cpp-netlib-0.10.1/ -L/usr/local/cpp-netlib-0.10.1/build/libs/network/src/  -lcppnetlib-client-connections -lcppnetlib-server-parsers -lcppnetlib-uri
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.