Archive

Archive for the ‘Linux’ Category

Linking to shared libraries in non-standard locations in Linux

March 12th, 2009 No comments

I wrote a CGI app in C++ which compiled and linked with no problem.  When I ran it, thud: 

error while loading shared libraries… can not open shared object file… no such file or directory

The problem is that programs don’t hard-code paths to shared libs.  This works great most of the time because the app simply searches the standard lib paths and find it.  However, if the shared lib is elsewhere, game over – runtime link error.

Since it was only this program that needed to link to the library, I used a linker option that adds a directory to the runtime library search path: the -rpath flag.  Since I was using g++ through a makefile, I passed the flag to the linker via -Wl, which – you guessed it – passed flags to the linker!  The full LDFLAGS were: -L/path/to/shared/lib -l[libname] -Wl,-rpath,/path/to/shared/lib.  The commas are a little weird and through me off at first, but they are correct.  You can read about the syntax here (for -Wl) and here (for -rpath) and here (for the combination).

Exactly what I wanted: the program can find the library at runtime in its non-standard location!

Categories: Linux, Programming Tags: , ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip
\n