LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 10: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, 03:32 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 05: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, 03:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Cheers,
Tink
 
  


Reply



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 09:59 PM
any links on linking, loading shared libraries, shared objects. etc? ananthbv Programming 0 02-03-2005 07:47 AM
error while loading shared libraries: libdb-4.1.so: cannot open shared object file putquery8581 Linux - Software 1 10-01-2004 07:03 AM
Linking to shared libraries? Griffon26 Programming 1 10-20-2001 05:29 PM
linking with shared libraries kobilevi Programming 0 03-01-2001 10:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:38 PM.

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
Open Source Consulting | Domain Registration