Thread: huh? ld can't find library that is in /usr/lib

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    3

    huh? ld can't find library that is in /usr/lib

    I'm trying to build dynagraph (a graph layout engine) but the linker can't find one of the libraries and I can't figure out why.

    Code:
    g++ -static -g main.o IncrCalledBack.o DuplicateStream.o createConfiguration.o -Lincrface -lincrface -Ldynadag -ldynadag -Lpathplot -lpathplot -Lfdp -lfdp -Lshortspline -lshortspline -Lvoronoi -lvoronoi -Lcommon -ldynagraph -L/usr/lib/graphviz -lagraph -lpathplan -lcdt -lagraph -lboost_thread -pthread -o dynagraph-whole
    /usr/bin/ld: cannot find -lagraph
    collect2: ld returned 1 exit status
    make: *** [dynagraph-whole] Error 1
    The libraries seem to be present:
    Code:
    $ ls -l /usr/lib/libagraph*
    -rw-r--r-- 1 root root   808 2008-02-08 13:57 /usr/lib/libagraph.la
    lrwxrwxrwx 1 root root    18 2008-05-27 16:56 /usr/lib/libagraph.so -> libagraph.so.4.0.0
    lrwxrwxrwx 1 root root    18 2008-04-24 17:38 /usr/lib/libagraph.so.4 -> libagraph.so.4.0.0
    -rw-r--r-- 1 root root 61336 2008-02-08 13:57 /usr/lib/libagraph.so.4.0.0
    The directory /usr/lib should be in ld's search path (I even tried adding -L/usr/lib just in case). So why is ld complaining? Any pointers or hints on troubleshooting would be much appreciated!

    Cheers,
    Z.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The liblagraph.so is the shared library. You need the .ar version to link to your code. Usually, those come from a "-devel" variant when you install, e.g. you have "blah.2.9.rpm", and a "blah-devel.2.9.rpm" (rpm is just one of several types of "installable package" - yours may be one of many others).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    3
    Quote Originally Posted by matsp View Post
    The liblagraph.so is the shared library. You need the .ar version to link to your code. Usually, those come from a "-devel" variant when you install, e.g. you have "blah.2.9.rpm", and a "blah-devel.2.9.rpm" (rpm is just one of several types of "installable package" - yours may be one of many others).

    --
    Mats
    Thanks for the suggestion Mats. I have the deb package libgraphviz-dev installed:
    Code:
    $ dpkg -l libgraphviz*
    [..]
    ii  libgraphviz-dev         2.16-3ubuntu2           graphviz libs and headers against which to build applications
    rc  libgraphviz3            2.12-4ubuntu3           rich set of graph drawing tools
    un  libgraphviz3-dev        <none>                  (no description available)
    ii  libgraphviz4            2.16-3ubuntu2           rich set of graph drawing tools
    un  libgraphviz4-dev        <none>                  (no description available)
    This package supplies the shared libraries:
    Code:
    $ dpkg -L libgraphviz-dev | grep agraph
    /usr/include/graphviz/agraph.h
    /usr/lib/pkgconfig/libagraph.pc
    /usr/lib/libagraph.la
    /usr/share/man/man3/agraph.3.gz
    /usr/lib/libagraph.so
    Could it be that the package is missing the .ar ?

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    3
    The problem appears to be related to the graphviz packages in Ubuntu 8.10. I installed from the latest stable graphviz sources and the linking problem goes away.

    However, I haven't found a satisfactory explanation. The libraries look very similar to those provided by the Ubuntu packages.

    Code:
    $ ls -l /usr/local/lib/ | grep agraph
    -rwxr-xr-x  1 root root      837 2008-05-28 14:50 libagraph.la
    lrwxrwxrwx  1 root root       18 2008-05-28 14:50 libagraph.so -> libagraph.so.4.0.0
    lrwxrwxrwx  1 root root       18 2008-05-28 14:50 libagraph.so.4 -> libagraph.so.4.0.0
    -rwxr-xr-x  1 root root   254507 2008-05-28 14:50 libagraph.so.4.0.0
    Cheers,
    Z.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Are you sure there's no other libagraph file(s) somewhere else?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    When you pass -lagraph to the linker, it's looking for a file named libagraph.a, no? If you want to statically link with libagraph.la, you have to explicitly pass that name to the linker.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 01:28 PM
  3. university library
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 09-10-2003, 03:05 PM
  4. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM