LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-07-2003, 11:38 AM   #1
devin
LQ Newbie
 
Registered: Apr 2003
Posts: 14

Rep: Reputation: 0
Shared libraries and linking.,


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:

./main
ld.so.1: ./main: fatal: libqt.so.2: open failed: No such file or directory
Killed

ldd main
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
/usr/platform/SUNW,Sun-Blade-100/lib/libc_psr.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).

Thanks in advance,

Devin
 
Old 04-07-2003, 04:32 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
In your .bashrc or .bash_profile
do
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
and see whether that does the trick.

Hope it helps!

Cheers,
Tink
 
Old 04-07-2003, 06:03 PM   #3
devin
LQ Newbie
 
Registered: Apr 2003
Posts: 14

Original Poster
Rep: Reputation: 0
Tinkster,

Thank you! This has fixed the problem.

Devin
 
Old 04-08-2003, 04:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Glad I could help!

Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking static and shared libraries in the KDevelop Environment tristanm Programming 15 11-27-2006 10:59 PM
any links on linking, loading shared libraries, shared objects. etc? ananthbv Programming 0 02-03-2005 08:47 AM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 08:03 AM
Linking to shared libraries? Griffon26 Programming 1 10-20-2001 06:29 PM
linking with shared libraries kobilevi Programming 0 03-01-2001 11:09 AM


All times are GMT -5. The time now is 05:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration