Linking to cpp-netlib

Discussion in 'Mac Programming' started by Wnt2bsleepin, Aug 8, 2013.

  1. Wnt2bsleepin macrumors newbie

    Oct 12, 2011
    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.

    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.

    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.
  2. ElectricSheep macrumors 6502


    Feb 18, 2004
    Wilmington, DE
    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:

    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

Share This Page