Results 1 to 2 of 2

Thread: ld ignores ld.so.conf?

  1. #1
    Join Date
    Aug 2007
    Beans
    190
    Distro
    Ubuntu

    ld ignores ld.so.conf?

    Hi,

    I am having troubles with setting /etc/ld.so.conf in order to add a directory to the default library search path.

    More specifically, I have already compiled a very simple shared library (libhello.so) which I previously tested that it works by placing it in /usr/local/lib and running ldconfig, and compiling the program with gcc main.c -lhello -o myprogr.

    Everything worked well. Now, I try to make it run from a custom directory which I previously added to /etc/ld.so.conf. I copy the library into that custom directory and than I run ldconfig.

    I know ldconfig works, because the real name of the lib is libhello.so.1 and after ldconfig, in that custom directory it appears a link file (libhello.so). Moreover, ldconfig -v | grep /pathtomycustomdir reports that the custom directory was considered.
    But when I run gcc main.c -lhello -o myprogr, the linker complains it cannot find libhello. I have to give the -Ldir option in order to compile my program. My guess is that ld ignores my entry in ld.so.conf.

    What I tried so far:
    *adding a path to the custom directory entry directly into /etc/ld.so.conf
    *adding a file in /etc/ld.so.conf.d directory with the .conf and containing the path to that custom directory.

    Can I set ld somehow in order to read the ld.so.conf?

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: ld ignores ld.so.conf?

    ld.so.conf has nothing to do with the compile time linker (ld)
    it only controls the runtime dynamic linker (ld.so)

    so you always need to set -Ldir or LD_RUN_PATH=dir when linking from non standard folders

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •