ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello
I use kDevelop to compile my GLUT source codes.But i dont like to make all those projects with all those files.I want to compile my GLUT using g++.
In my linker options from my kDevelop i click on the libraries: X11, Xext and Math.
Then i add -lglut -lGLU -lGL -lXi -lXmu to Additional Libraries.
So what do i need to type on a shell to compile my GLUT c plus plus file?
thanx Hylke
What do u mean with putting it in a makefile?
I typed g++ -o myprog myprog.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm and g++ -o myprog myprog.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lMath in a command line but both didn't work.
Maybe you could define "didn't work" a little bit better. Like with actual error output. We can't very well tell you how to fix it if you don't tell us what error you got.
Edit: Also, you should read up on Makefiles a bit. They will make your life easier. Do a Google search, and I bet you will find tons of information explaining them.
[hylke@DONKER testgameengine]$ g++ -o myprog main.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm
/home/hylke/tmp/ccnJVzhY.o(.text+0x3d): In function `main':
: undefined reference to `GameEngine::GameEngine[in-charge](int, int, bool, int, int, int)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x86): In function `main':
: undefined reference to `GameEngine::GameStart()'
/home/hylke/tmp/ccnJVzhY.o(.text+0x38e): In function `Render()':
: undefined reference to `GameEngine::DrawText(char*, float, float)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x3ad): In function `Render()':
: undefined reference to `GameEngine::DrawText(char*, float, float)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x3cc): In function `Render()':
: undefined reference to `GameEngine::DrawText(char*, float, float)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x3eb): In function `Render()':
: undefined reference to `GameEngine::DrawText(char*, float, float)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x667): In function `Render()':
: undefined reference to `GameEngine::DrawText(char*, float, float)'
/home/hylke/tmp/ccnJVzhY.o(.text+0x686): more undefined references to `GameEngine::DrawText(char*, float, float)' follow
/home/hylke/tmp/ccnJVzhY.o(.text+0x921): In function `End()':
: undefined reference to `GameEngine::~GameEngine [in-charge]()'
collect2: ld returned 1 exit status
It appears you aren't including the source for your GameEngine class. Is that in main.cpp, or a separate .cpp file? If it's in a separate .cpp file, you will have to include that in your list like so:
[hylke@DONKER testgameengine]$ g++ -o myprog main.cpp GameEngine.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm
GameEngine.cpp:1:24: GameEngine.h: No such file or directory
GameEngine.cpp:3: error: syntax error before `::' token
GameEngine.cpp:6: error: ISO C++ forbids declaration of `m_iWidth' with no type
GameEngine.cpp:6: error: `iWidth' was not declared in this scope
GameEngine.cpp:7: error: ISO C++ forbids declaration of `m_iGridX' with no type
GameEngine.cpp:7: error: `GridX' was not declared in this scope
GameEngine.cpp:8: error: ISO C++ forbids declaration of `m_iGridY' with no type
GameEngine.cpp:8: error: `GridY' was not declared in this scope
GameEngine.cpp:9: error: ISO C++ forbids declaration of `m_iGridZ' with no type
GameEngine.cpp:9: error: `GridZ' was not declared in this scope
GameEngine.cpp:10: error: ISO C++ forbids declaration of `bFullscreen' with no type
GameEngine.cpp:10: error: `fullscreen' was not declared in this scope
GameEngine.cpp:11: error: syntax error before `}' token
GameEngine.cpp:13: error: syntax error before `::' token
GameEngine.cpp:16: error: ISO C++ forbids declaration of `End' with no type
GameEngine.cpp:17: error: syntax error before `}' token
GameEngine.cpp:19: error: syntax error before `::' token
GameEngine.cpp:22: error: `seeder' was not declared in this scope
GameEngine.cpp:22: error: ISO C++ forbids declaration of `srand' with no type
GameEngine.cpp:23: error: `GL_TEXTURE_2D' was not declared in this scope
GameEngine.cpp:23: error: ISO C++ forbids declaration of `glEnable' with no typeGameEngine.cpp:24: error: ISO C++ forbids declaration of `CreateWindow' with no type
GameEngine.cpp:25: error: syntax error before `}' token
GameEngine.cpp:27: error: syntax error before `::' token
GameEngine.cpp:32: error: syntax error before `::' token
GameEngine.cpp:35: error: ISO C++ forbids declaration of `glutInitWindowPosition' with no type
GameEngine.cpp:35: error: initializer list being treated as compound expression
GameEngine.cpp:36: error: `m_iHeight' was not declared in this scope
GameEngine.cpp:36: error: ISO C++ forbids declaration of `glutInitWindowSize' with no type
GameEngine.cpp:36: error: initializer list being treated as compound expression
GameEngine.cpp:37: error: ISO C++ forbids declaration of `glClearColor' with no type
GameEngine.cpp:37: error: initializer list being treated as compound expression
GameEngine.cpp:37: warning: initialization to `int' from `double'
GameEngine.cpp:37: warning: argument to `int' from `double'
GameEngine.cpp:38: error: `GL_PROJECTION' was not declared in this scope
GameEngine.cpp:38: error: ISO C++ forbids declaration of `glMatrixMode' with no type
GameEngine.cpp:39: error: ISO C++ forbids declaration of `glLoadIdentity' with no type
GameEngine.cpp:40: error: ISO C++ forbids declaration of `glOrtho' with no type
GameEngine.cpp:40: error: initializer list being treated as compound expression
GameEngine.cpp:41: error: ISO C++ forbids declaration of `m_window' with no typeGameEngine.cpp:41: error: `glutCreateWindow' was not declared in this scope
GameEngine.cpp:42: error: `Render' was not declared in this scope
GameEngine.cpp:42: error: ISO C++ forbids declaration of `glutDisplayFunc' with no type
GameEngine.cpp:43: error: syntax error before `if'
GameEngine.cpp:47: error: `KeyboardHandling' was not declared in this scope
GameEngine.cpp:47: error: ISO C++ forbids declaration of `glutKeyboardFunc' with no type
GameEngine.cpp:48: error: `SpecialKeyboardHandling' was not declared in this scope
GameEngine.cpp:48: error: ISO C++ forbids declaration of `glutSpecialFunc' with no type
GameEngine.cpp:49: error: `MouseHandling' was not declared in this scope
GameEngine.cpp:49: error: ISO C++ forbids declaration of `glutMouseFunc' with no type
GameEngine.cpp:50: error: `Render' was not declared in this scope
GameEngine.cpp:50: error: ISO C++ forbids declaration of `glutIdleFunc' with no type
GameEngine.cpp:51: error: ISO C++ forbids declaration of `glutMainLoop' with no type
GameEngine.cpp:52: error: syntax error before `}' token
GameEngine.cpp:54: error: syntax error before `::' token
GameEngine.cpp:59: error: syntax error before `::' token
GameEngine.cpp:63: error: `message' was not declared in this scope
GameEngine.cpp:63: error: `strlen' was not declared in this scope
GameEngine.cpp:63: error: syntax error before `;' token
GameEngine.cpp:63: error: syntax error before `++' token
GameEngine.cpp:69: error: syntax error before `::' token
GameEngine.cpp:73: error: ISO C++ forbids declaration of `DrawText' with no typeGameEngine.cpp:73: error: initializer list being treated as compound expression
GameEngine.cpp:73: warning: initialization to `int' from `double'
GameEngine.cpp:73: warning: argument to `int' from `double'
GameEngine.cpp:105: error: syntax error before `if'
And when i add GameEngine.h
i got this:
Quote:
[hylke@DONKER testgameengine]$ g++ -o myprog main.cpp GameEngine.cpp GameEngine.h -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm
GameEngine.cpp:1:24: GameEngine.h: No such file or directory
GameEngine.cpp:3: error: syntax error before `::' token
GameEngine.cpp:6: error: ISO C++ forbids declaration of `m_iWidth' with no type
GameEngine.cpp:6: error: `iWidth' was not declared in this scope
GameEngine.cpp:7: error: ISO C++ forbids declaration of `m_iGridX' with no type
GameEngine.cpp:7: error: `GridX' was not declared in this scope
GameEngine.cpp:8: error: ISO C++ forbids declaration of `m_iGridY' with no type
GameEngine.cpp:8: error: `GridY' was not declared in this scope
GameEngine.cpp:9: error: ISO C++ forbids declaration of `m_iGridZ' with no type
GameEngine.cpp:9: error: `GridZ' was not declared in this scope
GameEngine.cpp:10: error: ISO C++ forbids declaration of `bFullscreen' with no type
GameEngine.cpp:10: error: `fullscreen' was not declared in this scope
GameEngine.cpp:11: error: syntax error before `}' token
GameEngine.cpp:13: error: syntax error before `::' token
GameEngine.cpp:16: error: ISO C++ forbids declaration of `End' with no type
GameEngine.cpp:17: error: syntax error before `}' token
GameEngine.cpp:19: error: syntax error before `::' token
GameEngine.cpp:22: error: `seeder' was not declared in this scope
GameEngine.cpp:22: error: ISO C++ forbids declaration of `srand' with no type
GameEngine.cpp:23: error: `GL_TEXTURE_2D' was not declared in this scope
GameEngine.cpp:23: error: ISO C++ forbids declaration of `glEnable' with no typeGameEngine.cpp:24: error: ISO C++ forbids declaration of `CreateWindow' with no type
GameEngine.cpp:25: error: syntax error before `}' token
GameEngine.cpp:27: error: syntax error before `::' token
GameEngine.cpp:32: error: syntax error before `::' token
GameEngine.cpp:35: error: ISO C++ forbids declaration of `glutInitWindowPosition' with no type
GameEngine.cpp:35: error: initializer list being treated as compound expression
GameEngine.cpp:36: error: `m_iHeight' was not declared in this scope
GameEngine.cpp:36: error: ISO C++ forbids declaration of `glutInitWindowSize' with no type
GameEngine.cpp:36: error: initializer list being treated as compound expression
GameEngine.cpp:37: error: ISO C++ forbids declaration of `glClearColor' with no type
GameEngine.cpp:37: error: initializer list being treated as compound expression
GameEngine.cpp:37: warning: initialization to `int' from `double'
GameEngine.cpp:37: warning: argument to `int' from `double'
GameEngine.cpp:38: error: `GL_PROJECTION' was not declared in this scope
GameEngine.cpp:38: error: ISO C++ forbids declaration of `glMatrixMode' with no type
GameEngine.cpp:39: error: ISO C++ forbids declaration of `glLoadIdentity' with no type
GameEngine.cpp:40: error: ISO C++ forbids declaration of `glOrtho' with no type
GameEngine.cpp:40: error: initializer list being treated as compound expression
GameEngine.cpp:41: error: ISO C++ forbids declaration of `m_window' with no typeGameEngine.cpp:41: error: `glutCreateWindow' was not declared in this scope
GameEngine.cpp:42: error: `Render' was not declared in this scope
GameEngine.cpp:42: error: ISO C++ forbids declaration of `glutDisplayFunc' with no type
GameEngine.cpp:43: error: syntax error before `if'
GameEngine.cpp:47: error: `KeyboardHandling' was not declared in this scope
GameEngine.cpp:47: error: ISO C++ forbids declaration of `glutKeyboardFunc' with no type
GameEngine.cpp:48: error: `SpecialKeyboardHandling' was not declared in this scope
GameEngine.cpp:48: error: ISO C++ forbids declaration of `glutSpecialFunc' with no type
GameEngine.cpp:49: error: `MouseHandling' was not declared in this scope
GameEngine.cpp:49: error: ISO C++ forbids declaration of `glutMouseFunc' with no type
GameEngine.cpp:50: error: `Render' was not declared in this scope
GameEngine.cpp:50: error: ISO C++ forbids declaration of `glutIdleFunc' with no type
GameEngine.cpp:51: error: ISO C++ forbids declaration of `glutMainLoop' with no type
GameEngine.cpp:52: error: syntax error before `}' token
GameEngine.cpp:54: error: syntax error before `::' token
GameEngine.cpp:59: error: syntax error before `::' token
GameEngine.cpp:63: error: `message' was not declared in this scope
GameEngine.cpp:63: error: `strlen' was not declared in this scope
GameEngine.cpp:63: error: syntax error before `;' token
GameEngine.cpp:63: error: syntax error before `++' token
GameEngine.cpp:69: error: syntax error before `::' token
GameEngine.cpp:73: error: ISO C++ forbids declaration of `DrawText' with no typeGameEngine.cpp:73: error: initializer list being treated as compound expression
GameEngine.cpp:73: warning: initialization to `int' from `double'
GameEngine.cpp:73: warning: argument to `int' from `double'
GameEngine.cpp:105: error: syntax error before `if'
g++: compilation of header file requested
GameEngine.h shouldn't go on the command line; it should be #included by whatever file needs it, which it looks like it is. You need to check that GameEngine.h exists and is in the directory with GameEngine.cpp.
looks like kDevelop uses automake. probably it would be a good idea to continue using that.
anyway, are you including GameEngine.h like #include <GameEngine.h> or like #include "GameEngine.h" ? It should be done the second way. I'm not entirely sure if that would cause the problem but it might.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.