LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2004, 11:40 AM   #1
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Rep: Reputation: 30
Question g++ compiler


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
 
Old 04-14-2004, 12:44 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
my guess would be

Code:
g++ -o myprog myprog.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm
This should really be put into a Makefile, assuming that it works at all -- like I said, it's a guess

btw, you might try -lMath instead of -lm
 
Old 04-14-2004, 01:17 PM   #3
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
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.
 
Old 04-14-2004, 03:05 PM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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.

Last edited by deiussum; 04-14-2004 at 03:08 PM.
 
Old 04-15-2004, 12:34 PM   #5
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
My errors:
Quote:
[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
EDIT: disable smilies.

Last edited by hylke; 04-15-2004 at 12:35 PM.
 
Old 04-15-2004, 01:07 PM   #6
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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:

g++ -o myprog main.cpp GameEngine.cpp -L/usr/X11R6/lib -lglut -lGLU -lGL -lXi -lXmu -lX11 -lXext -lm
 
Old 04-15-2004, 01:24 PM   #7
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
When i did that i got the following errors:
Quote:
[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
I gues that's just the same.
 
Old 04-15-2004, 01:27 PM   #8
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
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.
 
Old 04-15-2004, 01:29 PM   #9
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
it exist and it is in the same directory.
 
Old 04-15-2004, 01:32 PM   #10
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
I found this in a file of my directory where i compile the source code using kDevelop.

PHP Code:
####### kdevelop will overwrite this part!!! (begin)##########
bin_PROGRAMS testgameengine

## INCLUDES were found outside kdevelop specific part

testgameengine_SOURCES main.cpp GameEngine.cpp 
testgameengine_LDADD   
= -lglut -lGLU -lGL -lXi -lXmu -lm -lXext -lX11


EXTRA_DIST 
GameEngine.cpp GameEngine.h main.cpp 

####### kdevelop will overwrite this part!!! (end)############
# set the include path found by configure
INCLUDES= $(all_includes)
 
# the library search path.
testgameengine_LDFLAGS = $(all_libraries
 
Old 04-15-2004, 01:36 PM   #11
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
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.
 
Old 04-15-2004, 01:41 PM   #12
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
I use #include "GameEngine.h"
 
Old 04-15-2004, 01:43 PM   #13
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
I dunno what to tell you except that the compiler doesn't see a GameEngine.h in that directory
 
Old 04-15-2004, 01:57 PM   #14
hylke
Member
 
Registered: Apr 2004
Location: the Netherlands
Distribution: Ubuntu 7.04
Posts: 329

Original Poster
Rep: Reputation: 30
I wanted to put my GameEngine.h in my GameEngine.cpp and then i saw that i had used <'s instead of "s.
Thank you for your help.
Hylke

EDIT: I have another question:
I want to use texturing but then i need to add the glaux library.But how do i add the glaux library?
thanx again.
Hylke

Last edited by hylke; 04-15-2004 at 02:01 PM.
 
Old 04-15-2004, 02:09 PM   #15
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
I'm going to guess that you give -lglaux on the gcc line, and #include some header to use it, perhaps glaux.h. Not having glaux, I can't really know
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
C++ IDE+Compiler?Java IDE+compiler? Boby Linux - Software 3 05-31-2005 01:12 PM
Compiler conundrum: Which came first, a compiler, or it's source code? fr0zen Programming 21 01-29-2004 04:31 AM
No compiler to compiler the compliler NewtonIX Linux - Newbie 13 11-03-2003 05:32 AM
compile a compiler without a compiler? lackluster Linux - General 18 01-02-2003 07:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration