Main Page | Report Page

 

  Computers Forum Index » Computer - Graphics - API (Opengl) » beginner problem

Author Message
UNED
Posted: Thu Oct 13, 2005 1:05 am
 
hi,
i´m starting with graphic programing. Trying to make an OGL proyect i have problems with the linker using GLUT libraries. I explain myself:
I´m using Dev-cpp IDE to make my proyects. Following the FAQ seccion on the OGL´s web page ,(http://www.opengl.org/resources/faq/getting_started.html), i positioned the correct files on the correct directories.
Then a link the files correctly ( i think)
This is the compiler execute line: g++.exe main.o -o "Proyect2.exe" -L"D:/M2/Dev-Cpp/lib" lib/OpenGL32.Lib lib/Glu32.Lib lib/glut32.lib
and put a example code to test like this:

#include<stdlib.h>
#include <gl\glut.h>
#include<gl\gl.h>

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
}

int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("3D Tech- GLUT Tutorial");
glutDisplayFunc(renderScene);
glutMainLoop();
}



First problem: If i dont include "stdlib.h" then the compile log take out: "43 | D:\M2\Dev-Cpp\include\gl\glut.h | redeclaration of C++ built-in type `short' "
I dont understand.
But i put this include .
Then, the link options seems not work:

main.o(.text+0xe):main.cpp: undefined reference to `_imp__glClear'
main.o(.text+0x1c):main.cpp: undefined reference to `_imp__glBegin'
main.o(.text+0x3d):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x5e):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x7f):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x86):main.cpp: undefined reference to `_imp__glEnd'
main.o(.text+0x8d):main.cpp: undefined reference to `_imp__glFlush'
main.o(.text+0xce):main.cpp: undefined reference to `glutInit'
main.o(.text+0xda):main.cpp: undefined reference to `glutInitDisplayMode'
main.o(.text+0xee):main.cpp: undefined reference to `glutInitWindowPosition'
main.o(.text+0x102):main.cpp: undefined reference to `glutInitWindowSize'
main.o(.text+0x10e):main.cpp: undefined reference to `glutCreateWindow'
main.o(.text+0x11a):main.cpp: undefined reference to `glutDisplayFunc'
main.o(.text+0x11f):main.cpp: undefined reference to `glutMainLoop'



I think i make all good to use GLUT libraries, but it dont work. Could somebody help me please.
Thank you in advance

Pajaro.
 
manolopm
Posted: Thu Oct 13, 2005 1:05 am
 
The problem of the undefined reference: You must use the -lGL -lGLU
-lglut in the linker options.

The other probl. that you said about "stdlib.h" I don't know where it
comes from. I compile the code that you posted with and without the
stdlib in linux and goes as it should... a triangle in my screen.
 
Andreas Volz
Posted: Thu Oct 13, 2005 9:05 am
 
Am Thu, 13 Oct 2005 02:16:09 +0200 schrieb UNED:

Quote:
hi,
i__m starting with graphic programing. Trying to make an OGL proyect i
have problems with the linker using GLUT libraries. I explain myself:
I__m using Dev-cpp IDE to make my proyects. Following the FAQ seccion
on the OGL__s web
page ,(http://www.opengl.org/resources/faq/getting_started.html), i
positioned the correct files on the correct directories. Then a link
the files correctly ( i think) This is the compiler execute line:
g++.exe main.o -o "Proyect2.exe" -L"D:/M2/Dev-Cpp/lib"
lib/OpenGL32.Lib lib/Glu32.Lib lib/glut32.lib and put a example code
to test like this:

#include<stdlib.h
#include <gl\glut.h
#include<gl\gl.h

This is no real problem, but perhaps a hint for the future. You should
write...

Quote:
#include <GL/glut.h
#include <GL/gl.h

The Dev-C++ IDE includes the GNU gcc and accept both versions. But if
you ever plan to compile this software for Linux/Unix this saves some
trouble.

regards
Andreas
 
UNED
Posted: Thu Oct 13, 2005 1:05 pm
 
thanks for answer me. I`ve try to use this to the linker options:
g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lglut -lGL -lGLU

But compile log says me:
D:\M2\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lGL

like i´ve say there are "glut32.lib" "OpenGL32.lib" and "Glu32.lib" in the Dev-cpp\Lib directory.
Please, if you can help me again...
Lot of thanks
 
jbwest
Posted: Thu Oct 13, 2005 3:07 pm
 
"-lGL" means "link with "libGL.lib", right ? So, in your case the syntax would be "-lOpenGL32", right ?

OK, back to your original problem: glut and GLU maybe can call OpenGL, so order is important, OpenGL has to be the last library.

jbw
"UNED" <sanchezwarren@hotmail.com> wrote in message news:diliif$5q1$1@hefestos.uned.es...
thanks for answer me. I`ve try to use this to the linker options:
g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lglut -lGL -lGLU

But compile log says me:
D:\M2\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lGL

like i´ve say there are "glut32.lib" "OpenGL32.lib" and "Glu32.lib" in the Dev-cpp\Lib directory.
Please, if you can help me again...
Lot of thanks
 
UNED
Posted: Fri Oct 14, 2005 5:05 pm
 
OK, i put this options to the linker, at this way:

g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lopengl32 -lglu32 -lglut32

And the compile log keep the same errors:

Compilador: Default compiler
Building Makefile: "D:\M2\Dev-Cpp\Makefile.win"
Executando make...
make.exe -f "D:\M2\Dev-Cpp\Makefile.win" all
g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lopengl32 -lglu32 -lglut32

main.o(.text+0xe):main.cpp: undefined reference to `_imp__glClear'
main.o(.text+0x1c):main.cpp: undefined reference to `_imp__glBegin'
main.o(.text+0x3d):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x5e):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x7f):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x86):main.cpp: undefined reference to `_imp__glEnd'
main.o(.text+0x8d):main.cpp: undefined reference to `_imp__glFlush'
main.o(.text+0xce):main.cpp: undefined reference to `glutInit'
main.o(.text+0xda):main.cpp: undefined reference to `glutInitDisplayMode'
main.o(.text+0xee):main.cpp: undefined reference to `glutInitWindowPosition'
main.o(.text+0x102):main.cpp: undefined reference to `glutInitWindowSize'
main.o(.text+0x10e):main.cpp: undefined reference to `glutCreateWindow'

main.o(.text+0x11a):main.cpp: undefined reference to `glutDisplayFunc'
main.o(.text+0x11f):main.cpp: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status

make.exe: *** ["Proxecto] Error 1

Execución Terminada





Thnk you for reply me this time, could you help again, THX!
 
Thomas Jahns
Posted: Fri Oct 14, 2005 9:05 pm
 
Andreas Volz <usenet-spam-trap@brachttal.net> writes:
Quote:
Am Thu, 13 Oct 2005 02:16:09 +0200 schrieb UNED:

hi,
i__m starting with graphic programing. Trying to make an OGL proyect i
have problems with the linker using GLUT libraries. I explain myself:
I__m using Dev-cpp IDE to make my proyects. Following the FAQ seccion
on the OGL__s web
page ,(http://www.opengl.org/resources/faq/getting_started.html), i
positioned the correct files on the correct directories. Then a link
the files correctly ( i think) This is the compiler execute line:
g++.exe main.o -o "Proyect2.exe" -L"D:/M2/Dev-Cpp/lib"
lib/OpenGL32.Lib lib/Glu32.Lib lib/glut32.lib and put a example code
to test like this:

#include<stdlib.h
#include <gl\glut.h
#include<gl\gl.h

This is no real problem, but perhaps a hint for the future. You should
write...

#include <GL/glut.h
#include <GL/gl.h

Yes, it's a real problem, because #include <gl/gl.h> will include IRIS
GL instead of OpenGL headers on SGI (and some AIX and possibly other)
boxen.

Thomas Jahns
--
"Computers are good at following instructions,
but not at reading your mind."
D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9
 
jbwest
Posted: Fri Oct 14, 2005 9:05 pm
 
"UNED" <sanchezwarren@hotmail.com> wrote in message news:diok16$47r$1@hefestos.uned.es...
OK, i put this options to the linker, at this way:

g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lopengl32 -lglu32 -lglut32

And the compile log keep the same errors:

Compilador: Default compiler
Building Makefile: "D:\M2\Dev-Cpp\Makefile.win"
Executando make...
make.exe -f "D:\M2\Dev-Cpp\Makefile.win" all
g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lopengl32 -lglu32 -lglut32

main.o(.text+0xe):main.cpp: undefined reference to `_imp__glClear'
main.o(.text+0x1c):main.cpp: undefined reference to `_imp__glBegin'
main.o(.text+0x3d):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x5e):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x7f):main.cpp: undefined reference to `_imp__glVertex3f'
main.o(.text+0x86):main.cpp: undefined reference to `_imp__glEnd'
main.o(.text+0x8d):main.cpp: undefined reference to `_imp__glFlush'
main.o(.text+0xce):main.cpp: undefined reference to `glutInit'
main.o(.text+0xda):main.cpp: undefined reference to `glutInitDisplayMode'
main.o(.text+0xee):main.cpp: undefined reference to `glutInitWindowPosition'
main.o(.text+0x102):main.cpp: undefined reference to `glutInitWindowSize'
main.o(.text+0x10e):main.cpp: undefined reference to `glutCreateWindow'

main.o(.text+0x11a):main.cpp: undefined reference to `glutDisplayFunc'
main.o(.text+0x11f):main.cpp: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status

make.exe: *** ["Proxecto] Error 1

Execución Terminada





Thnk you for reply me this time, could you help again, THX!





It's not finding the libraries. And, the order is backwards also. is "libopengl32.lib" in DL/M2/Dev-Cpp/lib ?
(note the Case Of The Letters Also).

jbw
 
jbwest
Posted: Fri Oct 14, 2005 11:19 pm
 
"Thomas Jahns" <Thomas.Jahns@epost.de> wrote in message
news:87slv33mcv.fsf@tjahns.news.arcor.de...
Quote:
Andreas Volz <usenet-spam-trap@brachttal.net> writes:
Am Thu, 13 Oct 2005 02:16:09 +0200 schrieb UNED:

hi,
i__m starting with graphic programing. Trying to make an OGL proyect i
have problems with the linker using GLUT libraries. I explain myself:
I__m using Dev-cpp IDE to make my proyects. Following the FAQ seccion
on the OGL__s web
page ,(http://www.opengl.org/resources/faq/getting_started.html), i
positioned the correct files on the correct directories. Then a link
the files correctly ( i think) This is the compiler execute line:
g++.exe main.o -o "Proyect2.exe" -L"D:/M2/Dev-Cpp/lib"
lib/OpenGL32.Lib lib/Glu32.Lib lib/glut32.lib and put a example code
to test like this:

#include<stdlib.h
#include <gl\glut.h
#include<gl\gl.h

This is no real problem, but perhaps a hint for the future. You should
write...

#include <GL/glut.h
#include <GL/gl.h

Yes, it's a real problem, because #include <gl/gl.h> will include IRIS
GL instead of OpenGL headers on SGI (and some AIX and possibly other)
boxen.

Thomas Jahns
--
"Computers are good at following instructions,
but not at reading your mind."
D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9

Look like the OP doesn't know about cAse sEnsiTivTy.

jbw
 
Andy V
Posted: Sat Oct 15, 2005 1:16 am
 
UNED wrote:

Quote:
g++.exe main.o -o "Proxecto 2.exe" -L"D:/M2/Dev-Cpp/lib" -lopengl32
-lglu32 -lglut32 /

try -lglut32 -lglu32 -lopengl32

Order is important.

--
Andy V
 
 
Page 1 of 1    
All times are GMT
The time now is Wed Sep 03, 2014 12:34 am