LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-28-2004, 03:29 PM   #1
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Rep: Reputation: 30
Question OpenGL and SDL programming with Slackware


Hey all,

I've been trying to get my OpenGL programs (some of which make heavy use of SDL and SDL_mixer) to compile on Slackware (9.1 and 10.0), but no luck so far. I've tried all the various make variations as suggested by the glut-3.7 README file and the SDL README files, I've tried moving the header files around into various directories, but no luck so far. Since my error messages keep changing and are very numerous, I shall refrain from posting them here for now. My main question really is if anyone here has been able to code, compile and run programs that use both OpenGL and SDL on a Slackware distro. I know it works on SuSE and the like, but I've just never been able to get it to work on Slack. Getting it to work in Windows is a breeze of course, but *blegh* basically. Who wants their hands held anyway?



Well, off to .... I'll be hoping to hear from at least one person with a success story.



-zsejk
 
Old 07-28-2004, 06:23 PM   #2
jaMslack
LQ Newbie
 
Registered: Jun 2003
Distribution: Slackware current
Posts: 6

Rep: Reputation: 0
I really don't know whats the problem but I've compiled several OpenGL-SDL applications and not a problem so.. that's my succes story
 
Old 07-29-2004, 01:31 AM   #3
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Hehehe.... that's really all I needed, someone to tell me it *is* possible.



The main issues are libraries that can't be found, GLUT functions not working, SDL_audio.h being unfindable even though it's in the same directory as SDL.h, etc. Basically there's something new every time I try to recompile or move stuff around. I guess I just have to keep tinkering until it works. One question though: did you use the SDL stuffs already in Slackware, or did you get packages from libsdl.org? Same question for glut: did you go to the OpenGL site and download the glut package (3.7 say), or do you use the glut stuffs already in Slack?

Thanks!!!

-zsejk
 
Old 07-29-2004, 02:04 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
SDL does not require glut to run open GL as far I know (but glu.h instead)

Try use these flags :
Code:
gcc `sdl-config --cflags --libs` -L/usr/X11R6/lib -lGL -lGLU -lpthread -o program program.c
 
Old 07-29-2004, 11:19 AM   #5
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Hey,

Thanks for that, I'll try it in a few minutes (have to eat some breakfast first). The reason I need glut.h though is because I use stuff like glutIdleFunc and glutSwapBuffers etc.



-zsejk
 
Old 07-29-2004, 12:09 PM   #6
George666
Member
 
Registered: Nov 2003
Distribution: Slackware
Posts: 63

Rep: Reputation: 15
Quote:
Originally posted by zsejk
Hey,

Thanks for that, I'll try it in a few minutes (have to eat some breakfast first). The reason I need glut.h though is because I use stuff like glutIdleFunc and glutSwapBuffers etc.



-zsejk
Why are you using SDL and glut at the same time ?
 
Old 07-29-2004, 12:16 PM   #7
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Good question! Basically in the program I'm trying to run I used SDL for the sound effects and glut for the other stuff. I also use glu and regular gl of course, so basically it's the one program I want to get running. 'Cause if *it* runs, everything will run.

-zsejk
 
Old 07-29-2004, 02:36 PM   #8
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by Cedrik
SDL does not require glut to run open GL as far I know (but glu.h instead)

Try use these flags :
Code:
gcc `sdl-config --cflags --libs` -L/usr/X11R6/lib -lGL -lGLU -lpthread -o program program.c
Well, I tried that and then some. Here's what I ended up with:
Code:
bash-2.05b$ make program

g++ -O -I. -I/usr -I/usr/include  -L/usr/lib -L/lib -L/usr/X11R6/lib
 `sdl-config --cflags --libs` -lGL -lGLU -lglut -lpthread -lSDL
 -lSDL_mixer -o program program.o

/usr/lib/libglut.so: undefined reference to `XGetExtensionVersion'
/usr/lib/libglut.so: undefined reference to `XFreeDeviceList'
/usr/lib/libglut.so: undefined reference to `XQueryDeviceState'
/usr/lib/libglut.so: undefined reference to `XListInputDevices'
/usr/lib/libglut.so: undefined reference to `XFreeDeviceState'
/usr/lib/libglut.so: undefined reference to `XOpenDevice'
/usr/lib/libglut.so: undefined reference to `XmuLookupStandardColormap'
/usr/lib/libglut.so: undefined reference to `XSelectExtensionEvent'

collect2: ld returned 1 exit status

make: *** [program] Error 1
So it seems things are working mildly ok, only now I have this odd collection of things in my glut library that can't find their way.



-zsejk
 
Old 07-31-2004, 04:25 AM   #9
George666
Member
 
Registered: Nov 2003
Distribution: Slackware
Posts: 63

Rep: Reputation: 15
You need to link the X libraries to, try adding the following flags : -lX11 -lXmu

If you still get undefined references run

ldd /usr/X11R6/lib/libglut.so

This will give you a list of libraries glut needs, then it's just a matter of linking the ones which are missing.

Last edited by George666; 07-31-2004 at 04:28 AM.
 
Old 07-31-2004, 04:30 AM   #10
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
I feel it a little curious to use both glut and sdl libraries in a program as all glut functions have an equivalent in SDL
 
Old 07-31-2004, 09:36 AM   #11
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by George666
You need to link the X libraries to, try adding the following flags : -lX11 -lXmu

If you still get undefined references run

ldd /usr/X11R6/lib/libglut.so

This will give you a list of libraries glut needs, then it's just a matter of linking the ones which are missing.
I did remember to do the first part of your suggestion, but still the same error. I'll give the second part a try later today... who knows!



And Cedrik... I don't think GLUT provides sound events... does it? Which doesn't make it necessary to use GLUT, I realize that (just use SDL right?), but I have some programs using GLUT and not SDL, which I really don't feel like changing. So whether or not GLUT and SDL end up being able to work together in the same program, the very *least* thing I need is for GLUT to work by itself.

-zsejk
 
Old 07-31-2004, 09:45 AM   #12
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
did you put -L/usr/X11R6/lib before -lX11 ?

[edit]
From man glut :
An example X11/Unix compile line would look like:

cc -o foo foo.c -lglut -lGLU -lGL -lXmu -lXi -lXext -lX11 -lm

Last edited by Cedrik; 07-31-2004 at 09:48 AM.
 
Old 07-31-2004, 10:05 AM   #13
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Yeah, that's actually what I started out with. It can't find the -Xext though, but I will try your solution about the order of things. Right after I get Slakcware re-installed, that is.



-zsejk
 
Old 08-03-2004, 07:52 PM   #14
zsejk
Member
 
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Original Poster
Rep: Reputation: 30
Well, you all were right... I was wrong. Nothing needs to be done to get this to work in Slackware 10.0. Especially make sure you don't go installing GLUT by downloading it somewhere, because you'll likely be messing up links and libraries that are best left alone.

In a fresh Slackware install, my makefile looks as follows:
Code:
CC = g++

GCCFLAGS = -O

INCLUDE = -I. -I/usr/include

LDLIBS =   -lglut -lXext -lX11 -lXmu -lXi -lGL -lGLU -lm -lSDL -lSDL_mixer
LDFLAGS =   -L/usr/X11R6/lib -L/usr/lib -L/lib

program:
	$(CC) $(GCCFLAGS) $(INCLUDE) progam.c $(LDFLAGS) $(LDLIBS) -o program
The header includes inside the code are simply as follows:
Code:
#include <GL/glut.h>
#include <GL/gl.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>


-zsejk
 
  


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
Using SDL/OpenGL, need help. kornerr Programming 33 11-19-2005 11:19 PM
sdl / opengl - cant press up and right atrain Linux - Games 2 03-27-2005 11:29 PM
Question about SDL OpenGL and -lglut doody Programming 2 11-16-2004 04:17 PM
Using OpenGL (+SDL) for 2D programs R00ts Programming 4 07-16-2004 12:33 PM
OpenGL lighting with SDL MadCactus Programming 0 09-21-2003 11:52 AM


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