I also am having link problems with the symbols 'glutInitWithExit@12', 'glutCreateWindowWithExit@8' and
'glutCreateMenuWithExit@8'.
These symbols appear in the library file glut32.lib, but NOT in the library file libglut32.a.
I have checked the downloads for this file many times, from different sites, and have not been able to locate a library file for the format 'libXXXX.a' that contains the desired symbols.
Do I link in with the file glut32.lib?
If so, how do I do that if it is not in the required format?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#include <windows.h> // include windows header file
#include <gl/glut.h> // include OpenGLUT header file
#include <math.h> // include math header file
void myInit(); // function prototype for my initialization function
void myDisplay(); // function prototype for my display function
const int screenWidth = 640; // define width for scaling
const int screenHeight = 480; // define height for scaling and shifting
GLdouble A, B, C, D; // scale and shift values
const GLdouble PI = 3.14159265;
int main(int argc, char* argv[]) // main program function
{
glutInit(&argc, argv); // initialize the GLUT toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(640, 480); // set window size
glutInitWindowPosition(50, 100); // set window position on the screen
glutCreateWindow("Plotting f(x)"); // title and open the window
glutDisplayFunc(myDisplay); // register my display function
myInit(); // call my initialization function
glutMainLoop(); // begin endless main loop
return 0;
}
void myInit() // initialize Open GL state
{
}
void myDisplay() // draw my image
{
}
/******************************************/
// Any ideas ?????????
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(1)4.9.8.0 and XP Home
(2) Wayne Keens example
(3) Compiler: Default compiler
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\code\Untitled1.cpp" -o "C:\code\Untitled1.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -I"C:\Dev-Cpp\include\GL" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x15):Untitled1.cpp: undefined reference to `__glutInitWithExit@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x32):Untitled1.cpp: undefined reference to `__glutCreateWindowWithExit@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x50):Untitled1.cpp: undefined reference to `__glutCreateMenuWithExit@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x6b):Untitled1.cpp: undefined reference to `glClear@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x85):Untitled1.cpp: undefined reference to `glColor3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x92):Untitled1.cpp: undefined reference to `glBegin@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xa9):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xc0):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xd7):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xee):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xf6):Untitled1.cpp: undefined reference to `glEnd@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xfb):Untitled1.cpp: undefined reference to `glFlush@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x111):Untitled1.cpp: undefined reference to `glClearColor@16'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x11e):Untitled1.cpp: undefined reference to `glMatrixMode@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x126):Untitled1.cpp: undefined reference to `glLoadIdentity@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x14f):Untitled1.cpp: undefined reference to `glOrtho@48'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x192):Untitled1.cpp: undefined reference to `glutInitDisplayMode@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1a7):Untitled1.cpp: undefined reference to `glutInitWindowSize@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1b6):Untitled1.cpp: undefined reference to `glutInitWindowPosition@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1db):Untitled1.cpp: undefined reference to `glutDisplayFunc@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1e3):Untitled1.cpp: undefined reference to `glutMainLoop@0'
Execution terminated
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Simple. You did NOT link the libraries. There are no commands to be seen of the form
-lglut32
in your compile log.
Take a few minutes to look at the section in the thread "The Forum FAQ - Please Read First" covering the compile log, headers and libraries. It talks about the hows in some length.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Perhaps you made one of my favorite mistakes (its really hard to pick a favorite I make so darn many mistakes)....did you check the box next to the link options after you entered them.
I forget from time to time, the sound of a hard slap to the head clearly audible in the next county.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well it works now you were right it was the check box but I think I was confused. I had the add these commands to the linker checked. But when I checked the add the following when calling the compiler box it worked.
Thanks a ton.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can compile as a project, I just did my example that way to keep it as simple as possible. (In deference to ME ;-)
I know a couple if the folks here have answered that question before....a search should bring them up. I am on my way out the door to get my boy, I'll check back later and see if you found it...
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just want to add something i discovered recently:
All sorts of compiler errors may happen if you have a "glut.h" header that is not suited to MinGW.
For example, a glut.h made for Visual Studio may not add __stdcall to function prototypes, because those #ifdefs do not recognize MinGW. What happens next is a mismatch between the function names in your ".o" and the library (one with and the other without "...@number", or vice-versa). Also, there are other hacks int glut.h that interfere with mingw handling of libraries, such as the ATEXIT_HACK.
Having explained that, i really want to know:
***Why MinGW comes with libglut32.a but not with glut.h???***
--mac
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-08-11
Hi All,
My first post here. The GLUT topic caught my attention, it relates closely to what I am trying to do now, which is to port a finite element gui called cgx from linux to win. Have spent more than a week messing around with cygwin, couldn't get the GL/GLUT thing working there, found DevCpp, decided to try. Btw, DevCpp seems very comfortable, reminiscent, not surprisingly, of my many hours spent with Delphi 1 and 5.
Those many hours did not impart any awareness of GL issues or techniques.
I was able to follow the above instructions well enough to get drwayne's sample file linked without errors. A white cube -- it's not supposed to be grabbable, is it?
Light Knight's sample would not link for me. Also, some of the GL sample files would not compile. I thought this msg would be a long one -- I was even going to give a complete breakdown of glutming.zip contents and file by file destination. But now it's not necessary, because scolling up I noticed the 'lglu32' linker directive, which I had not noticed before. After adding that, the file linked like a charm.
So nothing left to add except big thanks for getting me started. Now I can start to get down to details in my project.
-l l
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
help please my dev c++ version is 4.9.8.0
and i try to compile your code and it says
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win"
make... running
make.exe -f "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"d:/Dev-Cpp/include/c++" -I"d:/Dev-Cpp/include/c++/mingw32" -I"d:/Dev-Cpp/include/c++/backward" -I"d:/Dev-Cpp/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/3ngin3/font_bmp" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/irrlicht/irrlicht/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/Jolt3D_v21/LIB/READY_LIB"
g++.exe main.o -o "glut.exe" -L"d:/Dev-Cpp/lib"
main.o(.text+0x15):main.cpp: undefined reference to `__glutInitWithExit@12'
main.o(.text+0x32):main.cpp: undefined reference to `__glutCreateWindowWithExit@8'
main.o(.text+0x50):main.cpp: undefined reference to `__glutCreateMenuWithExit@8'
main.o(.text+0x6b):main.cpp: undefined reference to `glClear@4'
main.o(.text+0x85):main.cpp: undefined reference to `glColor3f@12'
main.o(.text+0x92):main.cpp: undefined reference to `glBegin@4'
main.o(.text+0xa9):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xc0):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xd7):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xee):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xf6):main.cpp: undefined reference to `glEnd@0'
main.o(.text+0xfb):main.cpp: undefined reference to `glFlush@0'
main.o(.text+0x111):main.cpp: undefined reference to `glClearColor@16'
main.o(.text+0x11e):main.cpp: undefined reference to `glMatrixMode@4'
main.o(.text+0x126):main.cpp: undefined reference to `glLoadIdentity@0'
main.o(.text+0x14f):main.cpp: undefined reference to `glOrtho@48'
main.o(.text+0x192):main.cpp: undefined reference to `glutInitDisplayMode@4'
main.o(.text+0x1a7):main.cpp: undefined reference to `glutInitWindowSize@8'
main.o(.text+0x1b6):main.cpp: undefined reference to `glutInitWindowPosition@8'
main.o(.text+0x1db):main.cpp: undefined reference to `glutDisplayFunc@4'
main.o(.text+0x1e3):main.cpp: undefined reference to `glutMainLoop@0'
make.exe: *** [glut.exe] Error 1
Running canceled
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Re-read my examples. Your log shows that you did not link any of the proper libraries, which accounts for your linker errors.
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win"
make... running
make.exe -f "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"d:/Dev-Cpp/include/c++" -I"d:/Dev-Cpp/include/c++/mingw32" -I"d:/Dev-Cpp/include/c++/backward" -I"d:/Dev-Cpp/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/3ngin3/font_bmp" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/irrlicht/irrlicht/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/Jolt3D_v21/LIB/READY_LIB"
g++.exe main.o -o "glut.exe" -L"d:/Dev-Cpp/lib"
No link commands whatsoever. Note that if you use a project, you have to set up your link commands in the project options, not in the tools:compiler options (Note my first example did not use a project)
Also note that storing your projects in paths with spaces in them is a bad idea.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The OpenGLUT replacement library for GLUT is becoming
stable for both Unix and Win32. Converting a GLUT-based
program to OpenGLUT is a matter of:
1) Installing the OpenGLUT devpak
2) Changing #include<GL/glut.h> to #include <GL/openglut.h>
3) Linking against -lopenglut instead of -lglut
4) Defining the symbol -DOPENGLUT_STATIC to the compiler
5) Recompiling the application
We would appeciate feedback from the Dev-C++ community,
especially in relation to any problems or incompatibilities.
This is our first release that includes a DevPak and we're
interested to see your response.
I've tried to compile the first glut example by Wayne Keen and I got the following compile log:
Compiler: Default compiler
Building Makefile: "Z:\OpenGL\JustAnotherTest\Makefile.win"
Executing make clean
rm -f main.o GlutTest.exe
g++.exe -c main.cpp -o main.o -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++/mingw32" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++/backward" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include"
g++.exe main.o -o "GlutTest.exe" -L"C:/Arquivos de programas/devcpp/Dev-Cpp/lib" -mwindows -lglut32 -lopengl32
main.o(.text+0x15):main.cpp: undefined reference to __glutInitWithExit@12'
main.o(.text+0x32):main.cpp: undefined reference toglutCreateWindowWithExit@8'
main.o(.text+0x50):main.cpp: undefined reference to `glutCreateMenuWithExit@8'
make.exe: *** [GlutTest.exe] Error 1
Execution terminated
My OS: Windows 2000 Professional
Dev-C++ Version: 4.9.8.0
I've wrote #include "glut.h" instead #include <gl/glut.h>. I've included the glut.h header and the glut32.dll in the program's directory as well.
Thanks for any help ^_^
Eduardo Rebellis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One mostly unrelated question. You are compiling this as a windows project. Why are you doing that? Its a console program.
Note also that the local directory is not where the dll goes. It has to go in a path where the compiler looks for executable code. By default - Unix ancestry code does not look for such code in the current directory. It needs to go in either the Dev bin directory of your windows system32 directory.
Finally, you really do not want to install Dev in a directory with spaces in it, as you did. It willbite you eventually. Hard.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok this is a very strange error im getting with Glut. Read thru all the instructions posted but couldnt find a post with this error. The strange this is my code works at home but not in my work comp.
Version of Dev-cpp :4.9.9.1
OS : Win 2000
Compiler Log : Compiler: Default compiler
Building Makefile: "E:\Resource\game_assignment_icat\Makefile.win"
Executing make...
make.exe -f "E:\Resource\game_assignment_icat\Makefile.win" all
g++.exe code.o -o "walkthru.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32 -lglut32 -lopengl32 -lglu32
code.o(.eh_frame+0x11):code.c: undefined reference to `__gxx_personality_v0'
make.exe: *** [walkthru.exe] Error 1
Execution terminated
Thanx. Hope some1 can help here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I use the version of GLUT found at DevPaks.org (it's one of the webupdate sites by the way). It's the latest (really old still) version, and it's a static mingw library, instead of ptrpck's converted MS dynamic library.
It might work better for you than the "glutming" version...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also am having link problems with the symbols 'glutInitWithExit@12', 'glutCreateWindowWithExit@8' and
'glutCreateMenuWithExit@8'.
These symbols appear in the library file glut32.lib, but NOT in the library file libglut32.a.
I have checked the downloads for this file many times, from different sites, and have not been able to locate a library file for the format 'libXXXX.a' that contains the desired symbols.
Do I link in with the file glut32.lib?
If so, how do I do that if it is not in the required format?
Could you post a simple as possible example program that shows the effect you are seeing?
Wayne
// Here's a source file that generates my 3 linkage errors
/***************************************/
// Plotting f(x): a dot plot of a math function
// http://www.bloodshed.net/
#include <windows.h> // include windows header file
#include <gl/glut.h> // include OpenGLUT header file
#include <math.h> // include math header file
void myInit(); // function prototype for my initialization function
void myDisplay(); // function prototype for my display function
const int screenWidth = 640; // define width for scaling
const int screenHeight = 480; // define height for scaling and shifting
GLdouble A, B, C, D; // scale and shift values
const GLdouble PI = 3.14159265;
int main(int argc, char* argv[]) // main program function
{
glutInit(&argc, argv); // initialize the GLUT toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(640, 480); // set window size
glutInitWindowPosition(50, 100); // set window position on the screen
glutCreateWindow("Plotting f(x)"); // title and open the window
glutDisplayFunc(myDisplay); // register my display function
myInit(); // call my initialization function
glutMainLoop(); // begin endless main loop
return 0;
}
void myInit() // initialize Open GL state
{
}
void myDisplay() // draw my image
{
}
/******************************************/
// Any ideas ?????????
(1)4.9.8.0 and XP Home
(2) Wayne Keens example
(3) Compiler: Default compiler
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\code\Untitled1.cpp" -o "C:\code\Untitled1.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -I"C:\Dev-Cpp\include\GL" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x15):Untitled1.cpp: undefined reference to `__glutInitWithExit@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x32):Untitled1.cpp: undefined reference to `__glutCreateWindowWithExit@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x50):Untitled1.cpp: undefined reference to `__glutCreateMenuWithExit@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x6b):Untitled1.cpp: undefined reference to `glClear@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x85):Untitled1.cpp: undefined reference to `glColor3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x92):Untitled1.cpp: undefined reference to `glBegin@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xa9):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xc0):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xd7):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xee):Untitled1.cpp: undefined reference to `glVertex3f@12'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xf6):Untitled1.cpp: undefined reference to `glEnd@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0xfb):Untitled1.cpp: undefined reference to `glFlush@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x111):Untitled1.cpp: undefined reference to `glClearColor@16'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x11e):Untitled1.cpp: undefined reference to `glMatrixMode@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x126):Untitled1.cpp: undefined reference to `glLoadIdentity@0'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x14f):Untitled1.cpp: undefined reference to `glOrtho@48'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x192):Untitled1.cpp: undefined reference to `glutInitDisplayMode@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1a7):Untitled1.cpp: undefined reference to `glutInitWindowSize@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1b6):Untitled1.cpp: undefined reference to `glutInitWindowPosition@8'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1db):Untitled1.cpp: undefined reference to `glutDisplayFunc@4'
C:\DOCUME~1\Del\LOCALS~1\Temp/cc4Ybaaa.o(.text+0x1e3):Untitled1.cpp: undefined reference to `glutMainLoop@0'
Execution terminated
Thanks in advance.
Simple. You did NOT link the libraries. There are no commands to be seen of the form
-lglut32
in your compile log.
Take a few minutes to look at the section in the thread "The Forum FAQ - Please Read First" covering the compile log, headers and libraries. It talks about the hows in some length.
Wayne
By the way, copying from the first link is this thread, which presents my example, note that I said:
Compiling this as a simple file, I went to Tools:Compiler Options:Compiler:Add these Commands To The Linker Command Line
-lglut32 -lopengl32
And I go a compile log that looks like this:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\mycstuff\glutter.cpp" -o "C:\mycstuff\glutter.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lglut32 -lopengl32
Execution terminated
Compilation successful
Note how the link commands show up in my log. One way or another, your link commands did not happen.
Wayne
Perhaps you made one of my favorite mistakes (its really hard to pick a favorite I make so darn many mistakes)....did you check the box next to the link options after you entered them.
I forget from time to time, the sound of a hard slap to the head clearly audible in the next county.
Wayne
Well it works now you were right it was the check box but I think I was confused. I had the add these commands to the linker checked. But when I checked the add the following when calling the compiler box it worked.
Thanks a ton.
Since we arn't spost to compile as a project.. How do you remove that icky dos window?
You can compile as a project, I just did my example that way to keep it as simple as possible. (In deference to ME ;-)
I know a couple if the folks here have answered that question before....a search should bring them up. I am on my way out the door to get my boy, I'll check back later and see if you found it...
Wayne
I decided to use the 2nd example and that works!
Where can I learn more about this? I like Virtual Reality! :p
Nevermind, I found one at http://www.lighthouse3d.com/opengl/glut/
I just want to add something i discovered recently:
All sorts of compiler errors may happen if you have a "glut.h" header that is not suited to MinGW.
For example, a glut.h made for Visual Studio may not add __stdcall to function prototypes, because those #ifdefs do not recognize MinGW. What happens next is a mismatch between the function names in your ".o" and the library (one with and the other without "...@number", or vice-versa). Also, there are other hacks int glut.h that interfere with mingw handling of libraries, such as the ATEXIT_HACK.
Having explained that, i really want to know:
***Why MinGW comes with libglut32.a but not with glut.h???***
--mac
just follow instructions on the OpenGL compiler setup but additonal in your main.cpp add this above everything else (includes)
#define GLUT_DISABLE_ATEXIT_HACK
also make sure you have #include <windows.h> above the line #include <glut.h>
this should do the trick..
Posted by SomeOne:
ok here's a example just created your project and follow wayne's instructions on the compiler stuff but then in your main App use this code instead:
#define GLUT_DISABLE_ATEXIT_HACK
#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define _PI 3.14159
#define _2PI 2 * _PI
#define X 0
#define Y 1
#define Z 2
#define LON 0
#define LAT 1
#define DIS 2
#define RED 0
#define BLU 1
#define GRE 2
//camera
float fLookAtEyeR[3] = {0.0,0.0,0.0},
fLookAtEyeP[3] = {_PI,-1.222,5.0}, // start pos (should't use magic numbers though)
fLookAtCen[3] = {0.0,0.0,0.0},
fLookAtUp[3] = {0.0,-1.0,0.0};
//mouse - view interface
int iMoving,
iStartX,
iStartY,
iAuto = 0;
// Sample
#define RING_SEGS 20
#define RING_DIAM 3.0
float fRingV[RING_SEGS][3],
fRingC[RING_SEGS][3];
int fRingI[RING_SEGS];
float fRingAng = 0.0;
void MakeRing()
{
float fAng=0,
fAngStep,
fCRef, //color ref
fCSeg = _2PI/3; //color segments
fAngStep = _2PI / RING_SEGS;
for(int iCnt=0;iCnt<RING_SEGS;iCnt++,fAng+=fAngStep){
fRingI[iCnt] = iCnt;
// simple trig
fRingV[iCnt][X] = 0.0;
fRingV[iCnt][Y] = sin(fAng) * (RING_DIAM/2);
fRingV[iCnt][Z] = cos(fAng) * (RING_DIAM/2);
// make it pretty
if(fAng > fCSeg * 2){ // from blue to green
fCRef = fAng - (fCSeg*2);
fRingC[iCnt][RED] = 1.0;
fRingC[iCnt][BLU] = 1.0-fCRef / fCSeg;
fRingC[iCnt][GRE] = fCRef / fCSeg;
}
else if(fAng > fCSeg){ // from green to red
fCRef = fAng - fCSeg;
fRingC[iCnt][RED] = fCRef / fCSeg;
fRingC[iCnt][BLU] = 1.0;
fRingC[iCnt][GRE] = 1.0-fCRef / fCSeg;
}
else{
fCRef = fAng; // from red to blue
fRingC[iCnt][RED] = 1.0-fCRef / fCSeg;
fRingC[iCnt][BLU] = fCRef / fCSeg;
fRingC[iCnt][GRE] = 1.0;
}
}
}
void Ring()
{
glPushMatrix();
glTranslatef(0.0,-(RING_DIAM/2),0.0);
glRotatef(fRingAng,0.0,1.0,0.0);
glBegin(GL_LINE_LOOP);
for(int iCnt=0;iCnt<RING_SEGS;iCnt++){
glColor3f(fRingC[iCnt][RED],fRingC[iCnt][BLU],fRingC[iCnt][GRE]);
glVertex3f(fRingV[iCnt][X],fRingV[iCnt][Y],fRingV[iCnt][Z]);
}
glEnd();
glPopMatrix();
}
void P2RView() // polar to rectangular co-ords
{
float fT;
fLookAtEyeR[Y] = sin(fLookAtEyeP[LAT])*fLookAtEyeP[DIS];
fT = cos(fLookAtEyeP[LAT])*fLookAtEyeP[DIS];
fLookAtEyeR[X] = sin(fLookAtEyeP[LON])*fT;
fLookAtEyeR[Z] = cos(fLookAtEyeP[LON])*fT;
}
void DrawFloor(void)
{
float fCnt;
glBegin(GL_LINES);
glColor3f(1.0,0.0,1.0);
glVertex3f(-10.0,0.0,-10.0); //Bold line
glVertex3f(-10.0,0.0,10.0);
glColor3f(0.5,0.0,0.5);
for(fCnt = -9.0;fCnt <= 10.0;fCnt++){
glVertex3f(fCnt,0.0,-10.0);
glVertex3f(fCnt,0.0,10.0);
}
glBegin(GL_LINES);
glColor3f(1.0,0.0,1.0);
glVertex3f(-10.0,0.0,-10.0); //Bold line
glVertex3f(10.0,0.0,-10.0);
glColor3f(0.5,0.0,0.5);
for(fCnt = -9.0;fCnt <= 10.0;fCnt++){
glVertex3f(-10.0,0.0,fCnt);
glVertex3f(10.0,0.0,fCnt);
}
glEnd();
}
void Init(void)
{
glEnable(GL_DEPTH_TEST);
glClearColor (0.0,0.0,0.0,0.0);
MakeRing(); //or your stuff
}
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
P2RView();
gluLookAt(fLookAtEyeR[X],fLookAtEyeR[Y],fLookAtEyeR[Z],
fLookAtCen[X],fLookAtCen[Y],fLookAtCen[Z],
fLookAtUp[X],fLookAtUp[Y],fLookAtUp[Z]);
DrawFloor();
//Your objects go here - eg. Ring().
Ring();
// restore matrix and update display
glPopMatrix();
glutSwapBuffers();
}
void Reshape(int iW,int iH)
{
glViewport(0,0,iW,iH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(iH == 0)
gluPerspective(80,(float)iW,1.0,5000.0);
else
gluPerspective(80,(float)iW/(float)iH,1.0,5000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
#pragma argsused
void Keyboard(unsigned char cKey,int iX,int iY)
{
switch(cKey){
case 27: /* Escape key */
exit(0);
break;
case 'f':
glutFullScreen();
break;
case 'w':
glutReshapeWindow(300,300);
break;
case 'a':
iAuto = (iAuto == 1) ? 0 : 1;
break;
default:
break;
}
}
void Mouse(int iButton,int iState,int iX,int iY)
{
if(iButton == GLUT_LEFT_BUTTON && iState == GLUT_DOWN)
{
iMoving = GLUT_LEFT_BUTTON;
iStartX = iX;
iStartY = iY;
}
if(iButton == GLUT_RIGHT_BUTTON && iState == GLUT_DOWN){
iMoving = GLUT_RIGHT_BUTTON;
iStartX = iX;
iStartY = iY;
}
if((iButton == GLUT_LEFT_BUTTON || iButton == GLUT_RIGHT_BUTTON) && iState == GLUT_UP)
iMoving = 0;
}
void Motion(int iX,int iY)
{
float fTemp;
if(iMoving == GLUT_LEFT_BUTTON) {
fTemp = (float)( iX - iStartX ) / 200.0;
if(fTemp>_2PI)fTemp-=_2PI;
fLookAtEyeP[LON] = fLookAtEyeP[LON] + fTemp;
fTemp = (float) ( iY - iStartY ) / 200.0;
if(fLookAtEyeP[LAT]>_PI/2.0)fLookAtEyeP[LAT]=_PI/2.0;
fLookAtEyeP[LAT] = fLookAtEyeP[LAT] + fTemp;
iStartX = iX;
iStartY = iY;
glutPostRedisplay ( );
}
if(iMoving == GLUT_RIGHT_BUTTON)
{
fLookAtEyeP[DIS] = fLookAtEyeP[DIS] + (float)(iY - iStartY) / 10;
iStartY = iY;
glutPostRedisplay();
}
}
void Idlef(void)
{
static float fCyc1,fCyc2;
if(iAuto){
fCyc1 += 0.014f; // adjust as required by system,
if(fCyc1 > _2PI) fCyc1 -= _2PI; // Better sill, adjust by time.
fCyc2 += .021f; // <-this too.
if(fCyc2 > _2PI) fCyc2 -= _2PI;
fLookAtEyeP[LON] += 0.01f;
fLookAtEyeP[LAT] = sin(fCyc1) * (_PI/4.0f);
fLookAtEyeP[DIS] = 5.0f + sin(fCyc2) * 2.0f;
}
fRingAng += 1.0;
glutPostRedisplay();
}
int main(int iArgc,char** szpArgv)
{
glutInit(&iArgc,szpArgv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
glutInitWindowSize (600, 400);
glutCreateWindow (szpArgv[0]);
Init();
glutReshapeFunc (Reshape);
glutKeyboardFunc (Keyboard);
glutMouseFunc (Mouse);
glutMotionFunc (Motion);
glutDisplayFunc (Display);
glutIdleFunc (Idlef);
glutMainLoop ();
return 0;
}
have fun SomeOne
Hi All,
My first post here. The GLUT topic caught my attention, it relates closely to what I am trying to do now, which is to port a finite element gui called cgx from linux to win. Have spent more than a week messing around with cygwin, couldn't get the GL/GLUT thing working there, found DevCpp, decided to try. Btw, DevCpp seems very comfortable, reminiscent, not surprisingly, of my many hours spent with Delphi 1 and 5.
Those many hours did not impart any awareness of GL issues or techniques.
I was able to follow the above instructions well enough to get drwayne's sample file linked without errors. A white cube -- it's not supposed to be grabbable, is it?
Light Knight's sample would not link for me. Also, some of the GL sample files would not compile. I thought this msg would be a long one -- I was even going to give a complete breakdown of glutming.zip contents and file by file destination. But now it's not necessary, because scolling up I noticed the 'lglu32' linker directive, which I had not noticed before. After adding that, the file linked like a charm.
So nothing left to add except big thanks for getting me started. Now I can start to get down to details in my project.
-l l
help please my dev c++ version is 4.9.8.0
and i try to compile your code and it says
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win"
make... running
make.exe -f "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"d:/Dev-Cpp/include/c++" -I"d:/Dev-Cpp/include/c++/mingw32" -I"d:/Dev-Cpp/include/c++/backward" -I"d:/Dev-Cpp/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/3ngin3/font_bmp" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/irrlicht/irrlicht/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/Jolt3D_v21/LIB/READY_LIB"
g++.exe main.o -o "glut.exe" -L"d:/Dev-Cpp/lib"
main.o(.text+0x15):main.cpp: undefined reference to `__glutInitWithExit@12'
main.o(.text+0x32):main.cpp: undefined reference to `__glutCreateWindowWithExit@8'
main.o(.text+0x50):main.cpp: undefined reference to `__glutCreateMenuWithExit@8'
main.o(.text+0x6b):main.cpp: undefined reference to `glClear@4'
main.o(.text+0x85):main.cpp: undefined reference to `glColor3f@12'
main.o(.text+0x92):main.cpp: undefined reference to `glBegin@4'
main.o(.text+0xa9):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xc0):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xd7):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xee):main.cpp: undefined reference to `glVertex3f@12'
main.o(.text+0xf6):main.cpp: undefined reference to `glEnd@0'
main.o(.text+0xfb):main.cpp: undefined reference to `glFlush@0'
main.o(.text+0x111):main.cpp: undefined reference to `glClearColor@16'
main.o(.text+0x11e):main.cpp: undefined reference to `glMatrixMode@4'
main.o(.text+0x126):main.cpp: undefined reference to `glLoadIdentity@0'
main.o(.text+0x14f):main.cpp: undefined reference to `glOrtho@48'
main.o(.text+0x192):main.cpp: undefined reference to `glutInitDisplayMode@4'
main.o(.text+0x1a7):main.cpp: undefined reference to `glutInitWindowSize@8'
main.o(.text+0x1b6):main.cpp: undefined reference to `glutInitWindowPosition@8'
main.o(.text+0x1db):main.cpp: undefined reference to `glutDisplayFunc@4'
main.o(.text+0x1e3):main.cpp: undefined reference to `glutMainLoop@0'
make.exe: *** [glut.exe] Error 1
Running canceled
Re-read my examples. Your log shows that you did not link any of the proper libraries, which accounts for your linker errors.
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win"
make... running
make.exe -f "C:\Documents and Settings\PC-2004\Desktop\Soul Taker\3ngin3\glut\1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"d:/Dev-Cpp/include/c++" -I"d:/Dev-Cpp/include/c++/mingw32" -I"d:/Dev-Cpp/include/c++/backward" -I"d:/Dev-Cpp/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/3ngin3/font_bmp" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/irrlicht/irrlicht/include" -I"C:/Documents and Settings/PC-2004/Desktop/Soul Taker/game engines/Jolt3D_v21/LIB/READY_LIB"
g++.exe main.o -o "glut.exe" -L"d:/Dev-Cpp/lib"
No link commands whatsoever. Note that if you use a project, you have to set up your link commands in the project options, not in the tools:compiler options (Note my first example did not use a project)
Also note that storing your projects in paths with spaces in them is a bad idea.
Wayne
An OpenGLUT DevPak has been added to the devpak
repository:
http://devpaks.org/show.php?devpak=91
The OpenGLUT replacement library for GLUT is becoming
stable for both Unix and Win32. Converting a GLUT-based
program to OpenGLUT is a matter of:
1) Installing the OpenGLUT devpak
2) Changing #include<GL/glut.h> to #include <GL/openglut.h>
3) Linking against -lopenglut instead of -lglut
4) Defining the symbol -DOPENGLUT_STATIC to the compiler
5) Recompiling the application
We would appeciate feedback from the Dev-C++ community,
especially in relation to any problems or incompatibilities.
This is our first release that includes a DevPak and we're
interested to see your response.
http://www.openglut.org
Regards,
Nigel Stewart
Hi,
I've tried to compile the first glut example by Wayne Keen and I got the following compile log:
Compiler: Default compiler
Building Makefile: "Z:\OpenGL\JustAnotherTest\Makefile.win"
Executing make clean
rm -f main.o GlutTest.exe
g++.exe -c main.cpp -o main.o -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++/mingw32" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include/c++/backward" -I"C:/Arquivos de programas/devcpp/Dev-Cpp/include"
g++.exe main.o -o "GlutTest.exe" -L"C:/Arquivos de programas/devcpp/Dev-Cpp/lib" -mwindows -lglut32 -lopengl32
main.o(.text+0x15):main.cpp: undefined reference to
__glutInitWithExit@12' main.o(.text+0x32):main.cpp: undefined reference to
glutCreateWindowWithExit@8'main.o(.text+0x50):main.cpp: undefined reference to `glutCreateMenuWithExit@8'
make.exe: *** [GlutTest.exe] Error 1
Execution terminated
My OS: Windows 2000 Professional
Dev-C++ Version: 4.9.8.0
I've wrote #include "glut.h" instead #include <gl/glut.h>. I've included the glut.h header and the glut32.dll in the program's directory as well.
Thanks for any help ^_^
Eduardo Rebellis
One mostly unrelated question. You are compiling this as a windows project. Why are you doing that? Its a console program.
Note also that the local directory is not where the dll goes. It has to go in a path where the compiler looks for executable code. By default - Unix ancestry code does not look for such code in the current directory. It needs to go in either the Dev bin directory of your windows system32 directory.
Finally, you really do not want to install Dev in a directory with spaces in it, as you did. It willbite you eventually. Hard.
Wayne
I did as you said Wayne.
Everythig works for me
I use win xp, devc++4.9.9
Ok this is a very strange error im getting with Glut. Read thru all the instructions posted but couldnt find a post with this error. The strange this is my code works at home but not in my work comp.
Version of Dev-cpp :4.9.9.1
OS : Win 2000
Compiler Log : Compiler: Default compiler
Building Makefile: "E:\Resource\game_assignment_icat\Makefile.win"
Executing make...
make.exe -f "E:\Resource\game_assignment_icat\Makefile.win" all
g++.exe code.o -o "walkthru.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32 -lglut32 -lopengl32 -lglu32
code.o(.eh_frame+0x11):code.c: undefined reference to `__gxx_personality_v0'
make.exe: *** [walkthru.exe] Error 1
Execution terminated
Thanx. Hope some1 can help here.
Do a search on the distinctive error name
gxx_personality_vo
I think you will find what you seek.
:)
Wayne
I use the version of GLUT found at DevPaks.org (it's one of the webupdate sites by the way). It's the latest (really old still) version, and it's a static mingw library, instead of ptrpck's converted MS dynamic library.
It might work better for you than the "glutming" version...