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


Closed Thread
  Search this Thread
Old 08-31-2009, 02:08 AM   #1
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
linker issue


Hi

I am trying to compile one of my c++ codes in slackware 13 and I always get linking problems with SDL libraries.
How can I check the linking is correct for SDL libraries? Where can be a problem?
I always get undefined reference for SDL functions like SDL_init ...

Help, help
 
Old 08-31-2009, 09:33 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Is the SDL library installed?

Do you know where it is?
(eg "find /usr -name libsdl\*)

You would use "-lSDL" to link in the library, and something like "-L/usr/local/lib" if it is not installed in /lib or /usr/lib.
 
Old 08-31-2009, 10:36 AM   #3
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Yes I found the libraries:
Quote:
/usr/lib64/libSDL-1.2.so.0.11.2
/usr/lib64/libSDL_image-1.2.so.0
/usr/lib64/libSDL_image.la
/usr/lib64/libSDL_ttf-2.0.so.0
/usr/lib64/libSDL_net-1.2.so.0
/usr/lib64/libSDL_mixer-1.2.so.0.2.6
/usr/lib64/libSDL.la
/usr/lib64/libSDL_ttf-2.0.so.0.6.3
/usr/lib64/libSDL.so
/usr/lib64/libSDL_ttf.la
/usr/lib64/libSDL_net.la
/usr/lib64/libSDL_mixer.la
/usr/lib64/libSDL_mixer-1.2.so.0
/usr/lib64/libSDL_image-1.2.so.0.1.6
/usr/lib64/libSDL_ttf.so
/usr/lib64/libSDL-1.2.so.0
/usr/lib64/libSDL_mixer.so
/usr/lib64/libSDL_image.so
/usr/lib64/libSDL_net-1.2.so.0.0.7
/usr/lib64/libSDL_net.so
/usr/lib64/libSDLmain.a
But the link in process I didn't understand.
Quote:
Originally Posted by neonsignal View Post
You would use "-lSDL" to link in the library, and something like "-L/usr/local/lib" if it is not installed in /lib or /usr/lib.
What do you mean with -lSDL. Use it as a switch for what command? For ld, or gcc??
Sorry if the question is stupid I never done linking before.

It looks like that the trouble is with kdevelop4 - I just cannot create SDL application the way I did before.
I am starting consider the downgrade to kdevelop 3.5.5.

Last edited by hua; 08-31-2009 at 11:31 AM.
 
Old 08-31-2009, 03:00 PM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Those command line switches are for the linker 'ld'. The link is the final stage of an application build process, when all the individual parts get 'linked' together.

Because you are using a development environment, you don't see these stages explicitly. But you do have control over the flags/switches that are given at each stage.

The '-lSDL' is a flag that tells the linker to look for a particular library that your application requires. This flag would be somewhere in the libraries section of the project/subproject options.

A flag like '-L/usr/lib64' tells the linker where to search for library files. This flag (or at least the path) would be somewhere in the linker flags section of the project configuration options. You may not need this (/usr/lib64 would often be in the standard search path).

Note that this is a later stage than the compilation stage (when header files are being included). Just because the compiler 'gcc' can find the header files for a library does not mean that the loader 'ld' can find the binary files that are the compiled library code, because these files are normally in different places. The undefined reference errors you are getting indicate that the compilation step succeeded, but the link stage could not find the functions which were referred to by the header source code.

Incidentally, do you have a '/usr/lib' directory on the system?
 
Old 08-31-2009, 03:07 PM   #5
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Yes I do, these files are in it.
Quote:
crda
libGL.la
libGL.so
libGL.so.1
libGL.so.185.18.36
libGLcore.so.1
libGLcore.so.185.18.36
libcuda.so
libcuda.so.1
libcuda.so.185.18.36
libnvidia-tls.so.1
libnvidia-tls.so.185.18.36
libsyslinux.a
libvdpau.so
libvdpau.so.1
libvdpau.so.185.18.36
libvdpau_nvidia.so
libvdpau_nvidia.so.185.18.36
libvdpau_trace.so
libvdpau_trace.so.185.18.36
rpm
sendmail
siconv
syslinux
terminfo
trn
 
Old 09-01-2009, 05:15 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of http://www.linuxquestions.org/questi...erence-751268/.
 
  


Closed Thread



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
-libnetlink and c linker alaios Programming 2 06-19-2013 07:30 PM
linker issue - undefined reference error asif.kalim Programming 3 04-19-2008 05:18 AM
autotools/gcc linker issue fibbi Linux - Software 2 05-08-2006 10:38 PM
ld linker errors Ankit mittal Programming 1 09-30-2005 03:05 PM
Linker Sections DylanDylan Linux - General 0 07-19-2004 04:26 AM

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

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