Skip to main content
gamedev.net
🔒 Locked

errors comping simple program

Started by rausse 1 reply 450+ views
Original Post
rausse
rausse
I''m attempting to get OpenGL running on an OpenBSD system, and I''m running into a problem. I''m just trying to compile a very simple example program from NeHe, and I''m getting lots of errors like this: /tmp/ccc25811.o: Undefined symbol `_glutInit'' referenced from text segment glutInit is a function call that is defined in glut.h, and I would assume is implemented in the shared library libglut.so.3.7, which I have. I''m using the following compile command: gcc -Wall -o try try.c -I/usr/X11R6/include/ -I/usr/local/include/ -L/usr/local/lib/libglut.so.3.7 -L/usr/X11R6/lib/libGLU.so.1.3 -L/usr/X11R6/lib/libGL.so.1.2 -L/usr/X11R6/lib/libGLw.a Help?
bschwagg
bschwagg
It may help to toss your compile statement into a Makefile. This is an example makefile I used for a project last year in Unix/Linux. I don''t know how much you know about makefiles, but this worked for me. It should work, provided your link and include directories are correct. Let me know if it works, I usually develop using MSV C++ but want to start writing demos in linux again. Its just the best way to go...

CFLAGS= -I/eng/home/easgst25/include
LIBFLAGS = -L/eng/home/easgst25/lib
simple: simple.o
g++ ${CCFLAGS} ${LIBFLAGS} -o simple simple.o \
-lglut -lGLU -lGL -lm -lX11 -lXmu -lpthread

simple.o: simple.c
g++ ${CCFLAGS} -c simple.c
cha cha cha
rausse
rausse
Thanks! It did work. The problem was that I was trying to specifty the entire library with the -L flag. I needed instead to specify the library path with -L and the actual library with -l. I''m not really a C programmer, so I''m unfamiliar with these compiler flags. In the end, if you use a compile command like:

gcc -Wall -o try try.c -I/usr/X11R6/include/ -I/usr/local/include/ -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL

everything works out wonderfully. I agree that make''s definitely the way to go. Incase anyone''s interested, here''s my makefile.

COMP=gcc
FLAGS=-Wall
INC=-I/usr/X11R6/include/ -I/usr/local/include/
LIBPATH=-L/usr/local/lib -L/usr/X11R6/lib
LIBS=-lglut -lGLU -lGL

try: try.c
${COMP} ${FLAGS} -o try try.c ${INC} ${LIBPATH} ${LIBS}

clean:
rm -f try *~

Now on to the fun stuff....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.