LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   OpenGL and SDL programming with Slackware (https://www.linuxquestions.org/questions/slackware-14/opengl-and-sdl-programming-with-slackware-210728/)

zsejk 07-28-2004 03:29 PM

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 :study: .... I'll be hoping to hear from at least one person with a success story.

:)

-zsejk

jaMslack 07-28-2004 06:23 PM

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

zsejk 07-29-2004 01:31 AM

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

Cedrik 07-29-2004 02:04 AM

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

zsejk 07-29-2004 11:19 AM

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

George666 07-29-2004 12:09 PM

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 ?

zsejk 07-29-2004 12:16 PM

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

zsejk 07-29-2004 02:36 PM

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.

:scratch:

-zsejk

George666 07-31-2004 04:25 AM

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.

Cedrik 07-31-2004 04:30 AM

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

zsejk 07-31-2004 09:36 AM

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

Cedrik 07-31-2004 09:45 AM

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

zsejk 07-31-2004 10:05 AM

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

zsejk 08-03-2004 07:52 PM

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


All times are GMT -5. The time now is 05:30 PM.