LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-19-2010, 12:48 AM   #1
twwwater
Member
 
Registered: Nov 2008
Posts: 113
Blog Entries: 1

Rep: Reputation: 15
Question /usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference t


[ocean@slackware-mp 13:37:26]$ gcc -o test testsqlite3.c -lsqlite3
/usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference to `dlsym'
/usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference to `dlsym'
/usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference to `dlerror'
/usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference to `dlopen'
/usr/lib/gcc/i486-slackware-linux/4.4.4/../../../libsqlite3.so: undefined reference to `dlclose'

Hi, there!!! I don't know why that there's always show me this error. I googled this problem, and seems that glibc-solibs may goes wrong, So I reinstalled glibc , libtool and glibc-solibs, but the problem still exist, nothing helps. any one had met this kind of situation? anyone could give a suggestion about this? thank you very much!!!
 
Old 07-19-2010, 01:38 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

You need the library "libdl.so" (or equivalent).

1. Try simply adding "-ldl" to your compile/link command:
Code:
gcc -o test testsqlite3.c -lsqlite3 -ldl
2. If that doesn't work, see if you have a "libdl" anywhere (/usr/lib is a Pop Favorite):
Code:
find / -name "libdl*" -print 2>/dev/null
'Hope that helps .. PSM
 
Old 07-19-2010, 01:52 AM   #3
twwwater
Member
 
Registered: Nov 2008
Posts: 113

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Smile

Quote:
Originally Posted by paulsm4 View Post
Hi -

You need the library "libdl.so" (or equivalent).

1. Try simply adding "-ldl" to your compile/link command:
Code:
gcc -o test testsqlite3.c -lsqlite3 -ldl
thank you, this is really works!!! hummm... well, I had not ever added libdl while compiling, so,I do not know this is the problem, I had thought that my library may goes wrong!!! thanks so much for your helping!!!!
 
Old 07-20-2010, 02:32 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by twwwater View Post
thank you, this is really works!!! hummm... well, I had not ever added libdl while compiling, so,I do not know this is the problem, I had thought that my library may goes wrong!!! thanks so much for your helping!!!!
It wasn't your question, but anyway - I am strongly advise you against useage
'test' as name for test programs. There is already one - in the /usr/bin.
And if you by chance invoke your program as
Code:
test
instead of
Code:
./test
You'll run test from the /usr/bin and not yours.
While I ago I spent a lot of time to figure out that stupid error
 
Old 07-20-2010, 07:49 PM   #5
twwwater
Member
 
Registered: Nov 2008
Posts: 113

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Smile

Quote:
Originally Posted by Valery Reznic View Post
It wasn't your question, but anyway - I am strongly advise you against useage
'test' as name for test programs. There is already one - in the /usr/bin.
OK!!! I remember that now, I won't use it any more, thanks' for your suggestion!!!! ~_~!!!
 
Old 07-21-2010, 01:07 AM   #6
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 2,559

Rep: Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351
The error you encountered should be fixed for stuff that uses pkgconfig to get the flags for sqlite.
 
Old 07-21-2010, 06:41 AM   #7
twwwater
Member
 
Registered: Nov 2008
Posts: 113

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Smile

Quote:
Originally Posted by rworkman View Post
The error you encountered should be fixed for stuff that uses pkgconfig to get the flags for sqlite.
thanks for your reply, but, I do not get fully understand of this, you mean I can fixed this error by using the tool of pkgconfig or something others?
but the error I encountered is none of sqlite's business, it is the -ldl's problem. I just did not add the options "-ldl" here, then I got this error, although I did not get this kind of error by other linux.
so, could you please show me how to fixed this? the exactly step?
thank you so much!!!!
 
Old 07-21-2010, 11:26 AM   #8
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
If you know sqlite3 is installed in your system, you can get the needed C compiler flags when compiling the program with "pkg-config --cflags sqlite3". To link an executable with sqlite3, you need to pass the flags indicated with "pkg-config --libs sqlite3" in the link step (for a simple program, this is the same step as the previous one). So, for example, a small program using sqlite3 could be compiled as:

gcc `pkg-config --cflags sqlite3` -OTHER_FLAGS -o PROGRAM_NAME PROGRAM_SOURCES `pkg-config --libs sqlite3` -OTHER_LINK_FLAGS

And, to know if sqlite3 is installed in your system, you could use the following command:

pkg-config --exists sqlite3

This will return 0 when sqlite3 is installed with pkg-config, and something else if it's not. pkg-config is not something specific to Slackware. It's simply conveniently used by a good amount of programs and libraries so you can easily use pkg-config to get the needed flags.
 
1 members found this post helpful.
Old 07-21-2010, 07:57 PM   #9
twwwater
Member
 
Registered: Nov 2008
Posts: 113

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Thumbs up

Quote:
Originally Posted by rg3 View Post
If you know sqlite3 is installed in your system, you can get the needed C compiler flags when compiling the program with "pkg-config --cflags sqlite3". To link an executable with sqlite3, you need to pass the flags indicated with "pkg-config --libs sqlite3" in the link step (for a simple program, this is the same step as the previous one). So, for example, a small program using sqlite3 could be compiled as:

gcc `pkg-config --cflags sqlite3` -OTHER_FLAGS -o PROGRAM_NAME PROGRAM_SOURCES `pkg-config --libs sqlite3` -OTHER_LINK_FLAGS

And, to know if sqlite3 is installed in your system, you could use the following command:

pkg-config --exists sqlite3

This will return 0 when sqlite3 is installed with pkg-config, and something else if it's not. pkg-config is not something specific to Slackware. It's simply conveniently used by a good amount of programs and libraries so you can easily use pkg-config to get the needed flags.
yes, you are right, I almost forgot this, I had used this, and this is really useful for me. en, I used mysql before, mysql needs many kinds of libs, then, I googled this tool "pkg-config",
seems that $(pkd-config --cflags mysql) $(pkg-config --libs mysql)
but I did not get a fully understand of pkg-config at that time, but now, I got it. thank you so much!!!
 
  


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
/usr/X11R6/lib/libX11.so: undefined reference to `__ctype_toupper mathimca05 Linux - Newbie 1 12-17-2007 04:16 AM
/usr/lib/libgnomevfs-2.so.0: undefined symbol: g_thread_pool_set_sort_function yinglcs2 Linux - Software 0 12-08-2006 06:52 PM
gcc linking: undefined reference to just about everything shabbychef Programming 7 09-09-2005 08:42 PM
gcc ld error. Undefined reference redness Linux - Software 4 02-08-2005 02:01 AM
Undefined reference error using gcc with Redhat Linux 9.0 armesk Programming 2 08-28-2003 06:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:48 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