0

I am trying to get OpenGL and Glut running on Eclipse Linux FC13.

After spending two days on it, I admit that help is needed. On FC13 Eclipse, I see /usr/include/GL and /usr/include/SDL -- so the libs are there. I started Eclipse, and then tried to run a simple program on it, just like suggested here. However, two things were missing in those steps:

  1. Callisto could not be installed -- nothing was found from the repository
  2. GCC C++ Linker is not found anywhere for Eclipse 3.5.2.

When trying to run the program, I see this error:

Program does not exist

and sometimes

Binary not found

If I just run the "hello world" it works, but otherwise, those errors happen every time I try to include glut gl or sdl commands.

Here is an excerpt from the compiler error:

make all 
g++ -O2 -g -Wall -fmessage-length=0   -c -o tw.o tw.cpp
tw.cpp: In function ‘void main_loop_function()’:
g++ -o tw tw.o

Yes, apparently the compiler is not able to see the glu, gl, sdl and glut libraries.

Some suggestion on how to fix?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
ThreaderSlash
  • 1,313
  • 3
  • 27
  • 43

2 Answers2

2

You have to tell the compiler that your program uses additional libraries.

Use the -l argument

g++ -O2 -g -Wall -fmessage-length=0  -lglut -lGL -lGLU -lX11  -c -o tw.o tw.cpp

This should help against unsatisfied link errors.

You can set these in the properties of your Project. Properties->c/c++ Build->Settings->Tool Settings->Linker

josefx
  • 15,506
  • 6
  • 38
  • 63
  • Thanks. now the linker has the lib. Nice. – ThreaderSlash Aug 29 '10 at 20:05
  • Here is what it shows now: make all Building target: zdt4 Invoking: GCC C Linker gcc -LGL -LSDL -Lglut -o"zdt4" ./zdt4.o then.. it is down to one error message: collect2: ld returned 1 exit status make: *** [zdt4] Error 1 and a lot of message like this undefined reference to `glClear' undefined reference to `glViewport' undefined reference to `glutInit' some suggestion? – ThreaderSlash Aug 29 '10 at 20:21
  • that error message is gone - undefined reference to `glViewport'! nice. now just left this awkward message: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘key’ this declared in the top of the program as "bool key[321];". any idea? – ThreaderSlash Aug 29 '10 at 20:36
  • @ThreaderSlash your sourcefile ends with .c instead of .cpp so gcc will try to compile it as c source, c does not have the bool type. rename your source file to end with .cpp – josefx Aug 29 '10 at 21:02
  • at c++ project option, it doesn't have the option Properties->c/c++ Build->Settings->Tool Settings->Linker, therefore, it gives you error once you cann't setup the libs SDL, GLUT, GL. any suggestion? – ThreaderSlash Aug 29 '10 at 21:21
1

Check if the compiler is able to find the appropriate header files or not. If not, you are sure to get compiler errors. Try using the -I option to set the appropriate paths.

Once you've fixed that, check if there are any linker errors (undefined symbols/references or the sort). If you do: Try to set the library paths using the -L option and ask the compiler to link in the specific libraries by using the -l option. Note that the latter expects something like -lmath where in reality the library being linked in is actually called libmath.so or libmath.a (as the case may be).

dirkgently
  • 108,024
  • 16
  • 131
  • 187