ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Is there a way to specify where a program looks for its shared libraries ?
For example, I have created a program using the QT library under Linux. It compiles fine with no errors and appears to link to libqt.so.2 but I can not run this program because my program can't find libqt.so.2
For this example here are the outputs:
ld.so.1: ./main: fatal: libqt.so.2: open failed: No such file or directory
libqt.so.2 => (file not found)
libstdc++.so.2.10.0 => /usr/local/gnu/lib/libstdc++.so.2.10.0
libm.so.1 => /usr/lib/libm.so.1
libc.so.1 => /usr/lib/libc.so.1
libdl.so.1 => /usr/lib/libdl.so.1
When I link my program I have tried linking in two ways:
1. With -L$(QTDIR)/lib -lqt
2. With $(QTDIR)/lib/libqt.so.2 (as if it were just another object)
I know the easy solution would be add $(QTDIR)/lib to ld.so.conf but I do not have root access. Is there any way to tell GCC to link in the absolute path to libqt.so.2 (I know this would not be a very portable solution but I don't care right now).