LinuxQuestions.org
Register a domain and help support LQ
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 08-05-2010, 03:09 PM   #1
richman1234
LQ Newbie
 
Registered: Mar 2010
Distribution: Fedora12 & Angstrom
Posts: 22

Rep: Reputation: 0
error in compiling SDL code using gcc


Hello all,

I'm a newbie with linux and I'm getting an error when I try to compile my SDL program with gcc. Here's the command line I'm using to compile it:

$ gcc -o comp fosdl9_3.c -lSDL_ttf -lSDL -I/usr/include/SDL -I/usr/local/include/SDL

And here is the error message it's giving me:

/usr/bin/ld: /tmp/ccr3zqbS.o: undefined reference to symbol 'sin@@GLIBC_2.0'
/usr/bin/ld: not: 'sin@@GLIBC_2.0' is defined in DSO /lib/libm.so.6 so try adding it to the linker command line
/lib/libm.so.6: could not read symbols: Invalid operation
collect2: ld returned 1 exit status

I'm assuming this means I have to add "libm.so.6 to the compile command line, but I'm not sure how to do that. Any help or advice would be greatly appreciated!

Thanks in advance!
 
Old 08-05-2010, 06:10 PM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by richman1234 View Post
I'm assuming this means I have to add "libm.so.6 to the compile command line, but I'm not sure how to do that.
Try
Code:
$ gcc -o comp fosdl9_3.c -lm -lSDL_ttf -lSDL -I/usr/include/SDL -I/usr/local/include/SDL
 
1 members found this post helpful.
Old 01-30-2013, 10:00 AM   #3
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 634
Blog Entries: 2

Rep: Reputation: 97
Quote:
Originally Posted by David1357 View Post
Try
Code:
$ gcc -o comp fosdl9_3.c -lm -lSDL_ttf -lSDL -I/usr/include/SDL -I/usr/local/include/SDL
Thanks for that suggestion it worked for me. I had the same problem when I was trying to make a package for cwstation - a morse code sound generator (http://cwstation.sourceforge.net/).

src2pkg aborted without giving any useful error messages. So I made a slackbuild script and when I ran it, I got the same error message as in the OP. The problem was to include the "-lm" without patching the Makefile or config file.

The solution was to modify cwstation.SlackBuild as follows:
Code:
make LDFLAGS="-lm" || exit

Last edited by psionl0; 01-30-2013 at 10:01 AM.
 
Old 02-01-2013, 07:56 PM   #4
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
More generally, if ld is spitting out "undefined reference to symbol 'foo'" "'foo' is defined in DSO 'libbar.so'", you want to add -lbar to your linking options, assuming the library actually exists.
 
  


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
Problem compiling code with g++ that works for gcc Division_By_Zero Programming 2 05-21-2007 03:19 AM
SDL is installed, included and linked, but will not compile SDL code mansizerooster Programming 10 05-31-2006 05:18 AM
gcc warning compiling C code vose Programming 2 09-29-2004 11:58 AM
SDL error while compiling software icehenge Linux - Software 1 09-28-2004 05:06 PM
SDL Error While Compiling... Chryzmo Linux - Newbie 1 09-01-2003 01:20 AM


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