LinuxQuestions.org
Visit Jeremy's Blog.
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 08-30-2009, 10:30 AM   #1
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
SDL init undefined reference


Hi
I have started to use kdevelop4 (3.9.91) on my ne slackware64 13 Desktop. I was developing software which uses SDL in earlier version of slackware 12.2. (I don't know which version of kdevelop).
Now I tried use the same code in kdevelop4 and at build time I get an undefined reference for SDL_Init function. It gives no sense because in #include SDL/SDL.h I can see that SDL_Init function is included.

The export of code stands for me in copy the .cpp source of the main function into newly created c++ project in kdevelop4. I get lot more undefined reference messages for 26 SDL functions which I can locate in included header files.

I noticed that the SDL headers library changed a little and now I have lots of header files like SDL_video.h, SDL_config.h, SDL_main.h. There are 36 header files for SDL in the /usr/include/SDL folder. May it be that the old header file SDL.h have included everything in one and I need to Include more header files?

These is the list of existing header files in /usr/include/SDL/:
Quote:
SDL.h
SDL_active.h
SDL_audio.h
SDL_byteorder.h
SDL_cdrom.h
SDL_config.h
SDL_cpuinfo.h
SDL_endian.h
SDL_error.h
SDL_events.h
SDL_getenv.h
SDL_image.h
SDL_joystick.h
SDL_keyboard.h
SDL_keysym.h
SDL_loadso.h
SDL_main.h
SDL_mixer.h
SDL_mouse.h
SDL_mutex.h
SDL_name.h
SDL_net.h
SDL_opengl.h
SDL_platform.h
SDL_quit.h
SDL_rwops.h
SDL_stdinc.h
SDL_syswm.h
SDL_thread.h
SDL_timer.h
SDL_ttf.h
SDL_types.h
SDL_version.h
SDL_video.h
begin_code.h
close_code.h
These are the headers I have Included:
Quote:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include <cstdlib>
#include <SDL/SDL_video.h>
#include <iomanip>
Thanks for any suggestion
 
Old 08-30-2009, 10:48 AM   #2
Andrew85
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Hi,

I'm a new commer in Linux Graphics Programming field. Please may i know how can you get exactly enough 36 headers like that in SDL directory . For my case i always missed the header SDL_image.h .

I have tried to reinstall SDL_image-1.2.3.rpm and later SDL_image-1.2.7.rpm . For 1.2.3 it show no error but the header SDL_image.h still missing. And for 1.2.7-1 there are 2 dependencies failures : Libc.so.6 is missing and RTLD is missing. Can anyone suggest me a solution please.

I sincerely apologize if my post has created any inconvinience. And i hope to hear a reply soon.

Your sincerely

Andrew.
 
Old 08-30-2009, 11:06 AM   #3
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
I have the new slackware 13 distribution. It uses the package SDL 1.2.13. The main question is what linux distribution you are using? The version 13 of slackware is very new. (released 27.8.) I cannot help you with managing the new version of SDL package into your distribution. The only solution I know - install slack 13.
But as you can see it is possible that there are still some problems with it. Because the code I am using for my graphic application was running with no problem in previous version of slackware (12.2)
Regards
Zoltan
 
Old 08-31-2009, 01:10 AM   #4
mjsurette
Member
 
Registered: May 2005
Distribution: spiral, fedora
Posts: 65

Rep: Reputation: 18
An undefined reference is a linking issue, not a header issue. Check that you have the proper linking information for your libraries.

hth

Mike
 
Old 08-31-2009, 01:59 AM   #5
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Thanks for your reply.
Quote:
Originally Posted by mjsurette View Post
An undefined reference is a linking issue, not a header issue. Check that you have the proper linking information for your libraries.
Sorry that i am awkward but how can I do that?
 
Old 08-31-2009, 04:31 AM   #6
Andrew85
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by hua View Post
I have the new slackware 13 distribution. It uses the package SDL 1.2.13. The main question is what linux distribution you are using? The version 13 of slackware is very new. (released 27.8.) I cannot help you with managing the new version of SDL package into your distribution. The only solution I know - install slack 13.
But as you can see it is possible that there are still some problems with it. Because the code I am using for my graphic application was running with no problem in previous version of slackware (12.2)
Regards
Zoltan
Hi Zoltan, i used Red Hat Enterprise Linux 4 and i found that there always a librarie missing and header missing there.So any suggestion ? Should i switch to other OS ? Where can i download Slackware 13 ? And also Debian ?
 
Old 08-31-2009, 06:27 AM   #7
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Each distribution uses its own packaging system. If you cannot find the package for your distribution you have to take care about it yourself. (create a package from source or compile the source (usually C++ code) right into your distribution)
Since I have no experience with Red Hat linux I cannot guide you to implement a new version of SDL into it. There can be other dependencies which I do not know about. I can only guide you to use slackware. You can get it here:
http://www.slackware.com/getslack/torrents.php
Its a torrent iso - you can choose weather you use CDs or DVD, 32 bit or 64 bit.

But before this you need to know slackware is different and you need to learn the basic install process. (From my point of view its very simple, because I already walk through the install several times) If you decide to setup slackware you have to be prepared to solve possible "difficulties". I can help you with that.

I cannot tell you how difficult would be the other way - implementing the new SDL version into redhat. You have to decide yourself.
If you decide to try slackware - create a thread in linuxdistros > slackware > Newbie slackware user - install.
I will find your post and guide you there. There are lots of helpful guys (and girls) who will be happy to help out a newbie slackware users.
Good luck

Last edited by hua; 08-31-2009 at 06:33 AM.
 
Old 08-31-2009, 08:17 AM   #8
shuuhen
Member
 
Registered: Jun 2004
Distribution: Mac OS X 10.6.6, Gentoo Linux, FreeBSD 6.0
Posts: 127

Rep: Reputation: 20
The gcc info page will have much more info, but basically you want to do

gcc -lSDL -o sdl_program sdl_program.c

or something similar depending on how your project is set up. The -L option may also be of interest to you (read the info page for that one).
 
Old 08-31-2009, 08:50 AM   #9
mjsurette
Member
 
Registered: May 2005
Distribution: spiral, fedora
Posts: 65

Rep: Reputation: 18
Quote:
Originally Posted by shuuhen View Post
The gcc info page will have much more info, but basically you want to do

gcc -lSDL -o sdl_program sdl_program.c

or something similar depending on how your project is set up. The -L option may also be of interest to you (read the info page for that one).
gcc links libraries in the order that they are given, so you would actually need

gcc -o sdl_program sdl_program.c -lSDL

because your program generates references to libSDL.so

You might be interested in http://lazyfoo.net/SDL_tutorials/index.php

It shows how to set up SDL with various systems, including KDevelop.
 
Old 08-31-2009, 11:08 AM   #10
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Quote:
Originally Posted by mjsurette View Post
It shows how to set up SDL with various systems, including KDevelop.
Thanks its a very good link. My problem will be with the new kdevelop version (kdevelop4 v. 3.9.95).

I have used SDL exactly the way how it is showed on the link above before kdevelop version 3.9.91. I start a new project wizard which gives me the option of the simple SDL program. Probably this step makes everything for me what is needed for SDL library linking.

But now when I am creating a new project in kdevelop4 I cannot choose simple SDL program. It has very few project templates. So all the steps what the old kdevelop done for me in previous versions I need to do on my own. But how??

Quote:
gcc -o sdl_program sdl_program.cpp -lSDL
What does this command do? Compile the source with the SDL librarie or just generates some reference file to SDL libraries?
I would like to done this the way that my kdevelop build the executable directly from the kdevelop application. I was using build from the project menu.

I get this error:
Quote:
project2.cpp:7:24: error: project2.moc: No such file or directory
project2.cpp:22:24: error: QApplication: No such file or directory
project2.cpp: In constructor 'project2:: project2()':
project2.cpp:58: error: 'qApp' was not declared in this scope
project2.cpp: In member function 'void project2::setupActions()':
project2.cpp:84: error: 'qApp' was not declared in this scope

Last edited by hua; 08-31-2009 at 11:13 AM.
 
Old 08-31-2009, 12:19 PM   #11
mjsurette
Member
 
Registered: May 2005
Distribution: spiral, fedora
Posts: 65

Rep: Reputation: 18
Quote:
Originally Posted by hua View Post
Thanks its a very good link. My problem will be with the new kdevelop version (kdevelop4 v. 3.9.95).

I have used SDL exactly the way how it is showed on the link above before kdevelop version 3.9.91. I start a new project wizard which gives me the option of the simple SDL program. Probably this step makes everything for me what is needed for SDL library linking.

But now when I am creating a new project in kdevelop4 I cannot choose simple SDL program. It has very few project templates. So all the steps what the old kdevelop done for me in previous versions I need to do on my own. But how??


What does this command do? Compile the source with the SDL librarie or just generates some reference file to SDL libraries?
I would like to done this the way that my kdevelop build the executable directly from the kdevelop application. I was using build from the project menu.

I get this error:
I'm afraid I've never used kdevelop so I can't help you with that, but it looks like it's missing a project template (just a guess).

The command

gcc -o sdl_program sdl_program.cpp -lSDL

compiles your program and creates references to the libSDL.so library. If you prefer to have sdl linked in you'd add a -static directive. It would then load the referenced functions from libSDL.a directly into your program.

Usually this would be found in your Makefile.

Mike
 
Old 08-31-2009, 01:02 PM   #12
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by Andrew85 View Post
Hi,

I'm a new commer in Linux Graphics Programming field. Please may i know how can you get exactly enough 36 headers like that in SDL directory . For my case i always missed the header SDL_image.h .

I have tried to reinstall SDL_image-1.2.3.rpm and later SDL_image-1.2.7.rpm . For 1.2.3 it show no error but the header SDL_image.h still missing. And for 1.2.7-1 there are 2 dependencies failures : Libc.so.6 is missing and RTLD is missing. Can anyone suggest me a solution please.

I sincerely apologize if my post has created any inconvinience. And i hope to hear a reply soon.

Your sincerely

Andrew.
In some cases you'll have to install headers separately from the library. In other words, you'll often have the library installed but the headers to use it won't be there. You'll probably need to locate a version of the package ending in -dev or one that otherwise indicates it's for development.
Kevin Barry
 
  


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
undefined reference to.... crapodino Programming 1 01-13-2008 07:05 PM
undefined reference to... dimah Programming 3 12-27-2006 09:57 AM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM
undefined reference vkmgeek Programming 1 05-11-2006 06:37 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 03:01 AM

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

All times are GMT -5. The time now is 02:40 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
Open Source Consulting | Domain Registration