Freshly compiled c prgram has problems loading shared objects
Hello
I have a user account on a large computer at my university. There I am supposed to test some code, I developed at home. I successfully ported what needed to be ported, successfully compiled and linked my code. I defined on the command line Code:
gcc -o whatever whatever.c something.c -L. -llibrary1 -llibrary2 ... ./whatever I get the message: Code:
error while loading shared libraries: liblibrary1.so: cannot open shared object file: No such file or directory So my question: how can I tell the program to load the .so from the same path the program is? Do I need to export some env_var? If so, which env_var should be exported? Thanks for your help. raven |
Try first, then ask stupid questions...
Resolved:
export LD_LIBRARY_PATH to include ./ Then ist works. bye raven |
It's better to use the ./ at link-time, i.e. ./liblibrary1.so instead of -llibrary1. That will hard-code the path into the binary so you don't have to export the additional path if you start a new shell session later on. You should only use -l for installed libraries. All others should be explicitly-named with at least a path fragment and the full library name.
ta0kira |
All times are GMT -5. The time now is 07:17 AM. |