473,625 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Errors compiling game source code

4 New Member
I download a game's source code from internet.
this is the link RapidShare: Easy Filehosting

I tried to compile it, the main.cpp file. but it gave errors.
In file included from main.cpp
[Warning] no newline at end of file

can somebody help me?

this is the main.cpp code

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <GL/glut.h>
  3. #include "Marble.h"
  4. #include "Board.h"
  5. #include "Move.h"
  6. #include "Main.h"
  7.  
  8. int Xmouse, Ymouse;
  9.  
  10. GLfloat Zoom = -14.f;
  11. GLfloat Xrot = 0.f;
  12. GLfloat Yrot = 0.f;
  13. GLfloat Zrot = 0.f;
  14.  
  15. Node *SelectedNode = 0;
  16.  
  17. main(int argc, char **argv)
  18. {
  19. glutInit(&argc, argv);
  20. glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
  21. glutInitWindowPosition(100, 100);
  22. glutInitWindowSize(500, 500);
  23. glutCreateWindow(argv[0]);
  24.  
  25. MakeGameBoard();
  26. ResetGameBoard();
  27.  
  28. glClearColor(0.f, 0.f, 0.f, 0.f);
  29. glEnable(GL_DEPTH_TEST);
  30. glEnable(GL_LIGHT0);
  31. glEnable(GL_LINE_SMOOTH);
  32. glEnable(GL_BLEND);
  33. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  34. glLineWidth(1.3f);
  35. glShadeModel(GL_SMOOTH);
  36.  
  37. glMatrixMode(GL_PROJECTION);
  38. glLoadIdentity();
  39.  
  40. glMatrixMode(GL_MODELVIEW);
  41. glLoadIdentity();
  42.  
  43. GLfloat MatSpec[] = {1.0f, 1.0f, 1.0f, 1.f};
  44. GLfloat MatShine[] = {50.f};
  45. GLfloat DiffuseLight[] = {0.6f, 0.6f, 0.6f, 1.f};
  46. GLfloat LightPos[] = {1.f, 1.f, 1.f, 0.f};
  47.  
  48. glMaterialfv(GL_FRONT, GL_SPECULAR, MatSpec);
  49. glMaterialfv(GL_FRONT, GL_SHININESS, MatShine);
  50.  
  51. glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
  52. glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
  53.  
  54. glutDisplayFunc(display);
  55. glutReshapeFunc(reshape);
  56. glutKeyboardFunc(keyboard);
  57. glutMouseFunc(mouse);
  58. glutMotionFunc(motion);
  59. glutIdleFunc(idle);
  60.  
  61. glutMainLoop();
  62.  
  63. return(0);
  64. }
  65.  
  66. void display(void)
  67. {
  68. glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  69.  
  70. glMatrixMode(GL_MODELVIEW);
  71. glPushMatrix();
  72.  
  73. glTranslatef(0.f, 0.f, Zoom);
  74.  
  75. glRotatef(Xrot, 1.f, 0.f, 0.f);
  76. glRotatef(Yrot, 0.f, 1.f, 0.f);
  77. glRotatef(Zrot, 0.f, 0.f, 1.f);
  78.  
  79. RenderGameBoard(GL_RENDER);
  80.  
  81. glPopMatrix();
  82.  
  83. glutSwapBuffers();
  84. }
  85.  
  86. void reshape(int w, int h)
  87. {
  88. glViewport(0, 0, w, h);
  89. glMatrixMode(GL_PROJECTION);
  90. glLoadIdentity();
  91. gluPerspective(60.f, GLfloat(w) / GLfloat(h), 1.f, 1000.f);
  92. glMatrixMode(GL_MODELVIEW);
  93. }
  94.  
  95. void mouse(int button, int state, int x, int y)
  96. {
  97. switch(state)
  98. {
  99. case GLUT_UP:
  100. {
  101. break;
  102. }
  103. case GLUT_DOWN:
  104. {
  105. Xmouse = x;
  106. Ymouse = y;
  107.  
  108. switch(button)
  109. {
  110. case GLUT_LEFT_BUTTON:
  111. {
  112. CompletePendingMove();
  113.  
  114. Node *N = PickNode(x, y);
  115.  
  116. if(!N || N == SelectedNode)
  117. {
  118. SelectedNode = 0;
  119. }
  120. else if(MakeMove(SelectedNode, N))
  121. {
  122. JumpingNode = SelectedNode;
  123. SelectedNode = 0;
  124. }
  125. else
  126. {
  127. SelectedNode = N;
  128. }
  129.  
  130. break;
  131. }
  132. case GLUT_RIGHT_BUTTON:
  133. {
  134. break;
  135. }
  136. }
  137.  
  138. break;
  139. }
  140. }
  141.  
  142. glutPostRedisplay();
  143. }
  144.  
  145. void motion(int x, int y)
  146. {
  147. Xrot += GLfloat(y - Ymouse);
  148. Zrot += GLfloat(x - Xmouse);
  149.  
  150. Ymouse = y;
  151. Xmouse = x;
  152.  
  153. glutPostRedisplay();
  154. }
  155.  
  156. void keyboard(unsigned char key, int x, int y)
  157. {
  158. switch(key)
  159. {
  160. case '[':
  161. {
  162. Zoom -= 1.2f;
  163. break;
  164. }
  165. case ']':
  166. {
  167. Zoom += 1.2f;
  168. break;
  169. }
  170. }
  171.  
  172. glutPostRedisplay();
  173. }
  174.  
  175. void idle(void)
  176. {
  177. AnimateMovingMarbles();
  178.  
  179. glutPostRedisplay();
  180. }
  181.  
Dec 12 '08 #1
9 2370
JosAH
11,448 Recognized Expert MVP
That one is simple: add a newline character (press enter) at the last line of the file your compiler is whining about. (the Standard says that every source file should have a newline at the end of every line in the file).

kind regards,

Jos
Dec 12 '08 #2
gkhn86
4 New Member
thank you, I tried it, but there's no difference.

Dec 12 '08 #3
Banfa
9,065 Recognized Expert Moderator Expert
It looks like the problem is not in you main.cpp but in all your header files.

All lines of code in all files must end in a new line, check all the files in the project.
Dec 12 '08 #4
JosAH
11,448 Recognized Expert MVP
@gkhn86
Note that if you position your mouse between the two columns of the error message you can shift them from left to right so you can see which files contain the error. Also the number of error messages indicate that none of your .h files contain an end of line at the end of the file. Know how to use your tools.

kind regards,

Jos
Dec 12 '08 #5
gkhn86
4 New Member
thanks for all your help. I tried to do all your said, but I couldn't get rid of the errors. I add new line for all the .cpp and .h files. but this time it gave some other errors. I think there's a little error but I couldn't find it. there is 4 .cpp files, maybe that's why it's a bit complicated for me.

here is the orijinal project, maybe somebody can help me.
RapidShare Webhosting + Webspace
Dec 12 '08 #6
Banfa
9,065 Recognized Expert Moderator Expert
If you post the errors and the lines of source where your errors are occurring then we can help.

I personally do not feel like downloading source from an unknown website and seeing if I can make it compile. And even if I did that wouldn't necessarily solve your problems as we are using different platforms.
Dec 12 '08 #7
gkhn86
4 New Member
you're right, sorry.
so there are main.cpp, marble.cpp, move.cpp, board.cpp.
and main.h, marle.h, move.h, board.h.

i add new lines for the .h files. then compile the main.cpp file. and it gave new errors.
these are the new errors.

[Linker error] undefined reference to `glutInit'
[Linker error] undefined reference to `glutInitDispla yMode'
[Linker error] undefined reference to `glutInitWindow Position'
[Linker error] undefined reference to `glutInitWindow Size'
.
.
.
.
.
ld returned 1 exit status
Dec 12 '08 #8
Banfa
9,065 Recognized Expert Moderator Expert
OK this looks like one of 2 errors (or may be both depending on the number of undefined reference errors there are).

An undefined reference means the code linked referred to a symbol which was not found in any of the objects or libraries linked. This is normally achieve either by forgetting to include one of your source files, forgetting to include a library or making a typo in a source file (mistyping a name) although that is a little harder to do in C++.

You did not compile main.cpp, you compiled and linked it, that is having compiled it you attempted to link it into a complete program. You should have used a compile command line that at least looked something like
gcc main.cpp marble.cpp move.cpp board.cpp
You may have had other compiler switches and in fact a different command in place of gcc.

Additionally if those symbols (functions) were not in your code but in a library (the OpenGL library for instance) then you would have needed to include that library on the command line too.

You may need to find/download a copy of the openGL library for your platform if you do not already have it.
Dec 12 '08 #9
boxfish
469 Recognized Expert Contributor
Here's what I have to do to use openglut on Dev-C++:
From the Project menu, select Project Options.
Click on the Parameters tab.
In the linker box, put
-lopenglut -lglu32 -lopengl32 -lwinmm -lgdi32
and in the other two boxes put
-DOPENGLUT_STATI C

You're using glut and I have openglut, but it seems like basically the same thing. This is just a guess, but try the above with glut instead of openglut to see if it works:
-lglut -lglu32 -lopengl32 -lwinmm -lgdi32
and
-DGLUT_STATIC

Good luck with this.
Dec 12 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2337
by: Thomi Richards | last post by:
Hi, I'm trying to create a simple stack class using C++ and templates. Everything works well and good if I amke the class totally inline. However, as soon as I try to seperate the class into a .h and a .cpp file, gcc throws some strange linking errors. Compiling like this:
24
2483
by: Massimo Soricetti | last post by:
Hello, I'm not a C newbie, but I'm teaching C programming (well... FIRST programming and then C) to other guys these days and it's driving me to some reflexions on the language. It's not uncommon to forget a } writing code, and at compiling time get an error 18956778 lines after the mistake, in an otherwise absolutely correct piece of code. Or, sometimes in my journeys I got errors reported in a file, checked and found it correct, and...
7
7061
by: Brandon J. Van Every | last post by:
Anyone know of any "good" open source C# game projects out there? Something that actually has a game engine and some content done, so I can just fiddle with it and do interesting / goofy things. I hesitate to state genre preferences. I've been all over SourceForge and it's slim pickings in C# land, at least for projects that have actually gotten something done. I'll be doing my last round of sifting and searching tonight, then I'm...
2
1948
by: Justin Naidl | last post by:
A group of friends and I are doing a RPG (role-playing game) maker for a school project. It occured to us, however, that if you want the user to be able to have almost complete control over the contents of his/her game, that you would end up with a tiny executable and a huge datafile. We wanted to keep clear of this as disk accesses take a lot of time to do and there would be a huge load of them to do this part. We could very easily...
3
4370
by: walkeraj | last post by:
I'm trying to compile an open source game called IVAN , and I'm able to compile it from a makefile, but not from an IDE. I have attempted to recreate the way the makefile compiles the project as closely as possible, yet I'm getting odd linking errors. I think I've traced it to some kind of problem with the SDL libraries it uses, yet I can't explain why it will compile from the makefile and not from the IDE. I have made sure that the ide...
4
1924
by: kimiraikkonen | last post by:
Hello dear experts, New to programming and while surfing the net to learn some examples, this C++ (maybe C, but source file name's extension is "cpp") game sample gave a lot of errors with the latest Dev C++ compiler. Maybe there are headers which do not exist or something wrong about "declerations"??? Where's the fault and possible reasons? With seeing that kind of errors even at the beginning of C++ programming, i become very...
13
3801
by: Albert | last post by:
Hi I'm using the lcc compiler for win32. I tried compiling a program but there's an error stating: "cpp: Can't open input file clrscr()" I don't get it - I've included <tcconio.h>. (strange why they couldn't have just left it as <conio.h>?): #include <tcconio.h> // code
3
1517
by: algatt | last post by:
Hello, I am trying to compile some source code from http://www.cse.ust.hk/~yike/prtree/ (source code: http://www.cse.ust.hk/~yike/prtree/prtree.tgz) but it will result from many errors ~365. Can this happen due to difference in compilers? I am using gcc latest version and the original source code was created in 2002. Any help? Thanks.
60
4074
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On May 3, 8:09 am, apati...@gmail.com wrote: A programmer that uses Vista? :O Vista is a hog of an operating system. Downgrade to Windows XP or get yourself a Linux distro.
0
8251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8352
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.