Find the answer to your Linux question:
Results 1 to 4 of 4
I started out programming with MS Visual C++ so my understanding of what's going on under-the-hood when compiling is still sketchy. I'm just getting my head around make files and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Location
    Brockville, Ontario, Canada
    Posts
    74

    Shared libraries - Things work when linking, but not run tim


    I started out programming with MS Visual C++ so my understanding of what's going on under-the-hood when compiling is still sketchy. I'm just getting my head around make files and compiler flags and linking flags, etc.

    I'm trying to link in two shared libraries to my project (A C++/QT/Matlab project). I just recently moved these two libraries into a subdirectory and I thought I added the appropriate linking path. When I run gmake it seems to complete fine, but when I go to actually run the program I'm told it can't find one of those shared libraries. What am I missing here? Everything worked fine when the libraries were in the root of the project, but now with them in a subdirectory (with -Lsomesubdirectory set) I can't run the program.

    Thanks in advance.

    Stu

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575

    Re: Shared libraries - Things work when linking, but not run

    Quote Originally Posted by sadohert
    but when I go to actually run the program I'm told it can't find one of those shared libraries. What am I missing here?
    When you try to run the programme the loader loads to the memory the shared
    libraries your programme requires.It looks for those libraries in certain standard
    directories.If it can't find them it gives you an error message.To make it
    search in additional directories put their names in the enviromental
    variable LD_LIBRARY_PATH
    To learn more you can have a look at the man page for ld.so

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Location
    Brockville, Ontario, Canada
    Posts
    74
    AHHHHHHH, I see! Beautiful. Okay, so, I've already got myself a shortcut to a terminal that sets up LD_LIBRARY_PATH for some Matlab specific stuff, and now I've added the path to the shared libraries.... and I guess if I were ever deploying this application I'd have to drop these libraries into the standard /usr/lib.... type places, or expect the person installing to update LD_LIBRARY_PATH (although not likely).

    ORRRR, I guess the libraries can just stay in the same place as the program binary and they will be found at runtime (although my original goal was to clean up the directory structure)..... ORRRR< I guess build my binary into a subdir called $ProgramROOT/bin and dump the shared libraries in there too??

    Okay, things are starting to seem less like hebrew. Thanks SLH

  4. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by sadohert
    AHHHHHHH, I see! Beautiful. Okay, so, I've already got myself a shortcut to a terminal that sets up LD_LIBRARY_PATH for some Matlab specific stuff, and now I've added the path to the shared libraries.... and I guess if I were ever deploying this application I'd have to drop these libraries into the standard /usr/lib.... type places, or expect the person installing to update LD_LIBRARY_PATH (although not likely).

    ORRRR, I guess the libraries can just stay in the same place as the program binary and they will be found at runtime (although my original goal was to clean up the directory structure)..... ORRRR< I guess build my binary into a subdir called $ProgramROOT/bin and dump the shared libraries in there too??

    Okay, things are starting to seem less like hebrew. Thanks SLH
    Another alternative would be to install the libs somewhere and add symlinks to them in /usr/lib.

Posting Permissions

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