LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-09-2003, 02:07 AM   #1
dtheorem
Member
 
Registered: Sep 2003
Location: Winnipeg, MB, CA
Distribution: LinuxMint
Posts: 101

Rep: Reputation: 15
SDL Help


Hey, guys! I just installed SDL-devel and SDL_gfx to do some primitive drawing, but I can't compile anything. It says ": undefined reference to " and then whatever function I want to use, like circleColor or lineColor. I can plot pixels the usual way because it doesn't require SDL_gfx, so I know it's all set up properly. Does anyone know what I need to do? Do I need to pass something else to gcc to get it to work? I compile with

g++ -o name name.cpp `sdl-config --cpflags --libs`

Maybe something referencing SDL_gfxPrimitives.h? I couldn't find anything on google.
 
Old 11-04-2004, 04:38 AM   #2
EPITAPH-XV
LQ Newbie
 
Registered: Aug 2003
Posts: 1

Rep: Reputation: 0
SDL_gfx

Well, to use C++ you will have to learn how to link the libraries you are using. The `sdl-config --libs` part links the normal SDL libraries, you can see what it does by running the script by itself. On my system it is;

$>sdl-config --libs
-L/usr/lib -lSDL -lpthread

Learn what these flags do. -L for showing the path to what you want to link, -l for linking the compiled library binary to your program. On my system they are named like libSDL.a, libSDL_gfx.a . -lSDL links libSDL.a for example. /usr/lib is generally the place on my system where most compiled and archived libraries go. So what you need to add is a -lSDL_gfx at the end of your compilation/linking line.

Just including the header of a library does not work, unless all the definitions are inside that header. Sometimes this is the case. Most of the time, not. Learn what a declaration and definition is and why/how they are separated.

You might ask; why does, for example, just #include <iostream> let me use the std::cin, std::cout objects without visibly linking anything even though definitions are not in that header or in anywhere which it #includes? the answer is, they already get linked when you invoke g++. The library's name is libstdc++.a or similar on my system. A call to g++ links it automatically. If you want to demonstrate, you can also try to link it manually and use gcc itself. But g++ does a few more things. So it is pointless to use gcc and repeat what g++ readily does.

Read some Makefile s and learn to write your own, and you'll get better used to this.

PS: I had a problem using functionColor style functions in SDL_gfx, I never asked anyone, but when I used the functionRGBA style functions I got results, so I started using those instead.

I realize I am quite late but I hope someone else reads and makes use of this.
Happy coding.

Last edited by EPITAPH-XV; 11-04-2004 at 04:40 AM.
 
  


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
SDL issues with 10.1 -> 10.2 Vgui Slackware 1 09-20-2005 03:22 AM
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 07:50 AM
about SDL dt_ashok Programming 1 12-01-2004 03:16 PM
Sdl timcrafton Linux - Games 8 10-13-2004 01:11 PM
Sdl? tundra Linux - General 5 05-03-2003 08:17 AM


All times are GMT -5. The time now is 03:56 PM.

Main Menu
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