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 -
-
#include <GL/glut.h>
-
#include "Marble.h"
-
#include "Board.h"
-
#include "Move.h"
-
#include "Main.h"
-
-
int Xmouse, Ymouse;
-
-
GLfloat Zoom = -14.f;
-
GLfloat Xrot = 0.f;
-
GLfloat Yrot = 0.f;
-
GLfloat Zrot = 0.f;
-
-
Node *SelectedNode = 0;
-
-
main(int argc, char **argv)
-
{
-
glutInit(&argc, argv);
-
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
-
glutInitWindowPosition(100, 100);
-
glutInitWindowSize(500, 500);
-
glutCreateWindow(argv[0]);
-
-
MakeGameBoard();
-
ResetGameBoard();
-
-
glClearColor(0.f, 0.f, 0.f, 0.f);
-
glEnable(GL_DEPTH_TEST);
-
glEnable(GL_LIGHT0);
-
glEnable(GL_LINE_SMOOTH);
-
glEnable(GL_BLEND);
-
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
glLineWidth(1.3f);
-
glShadeModel(GL_SMOOTH);
-
-
glMatrixMode(GL_PROJECTION);
-
glLoadIdentity();
-
-
glMatrixMode(GL_MODELVIEW);
-
glLoadIdentity();
-
-
GLfloat MatSpec[] = {1.0f, 1.0f, 1.0f, 1.f};
-
GLfloat MatShine[] = {50.f};
-
GLfloat DiffuseLight[] = {0.6f, 0.6f, 0.6f, 1.f};
-
GLfloat LightPos[] = {1.f, 1.f, 1.f, 0.f};
-
-
glMaterialfv(GL_FRONT, GL_SPECULAR, MatSpec);
-
glMaterialfv(GL_FRONT, GL_SHININESS, MatShine);
-
-
glLightfv(GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
-
glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
-
-
glutDisplayFunc(display);
-
glutReshapeFunc(reshape);
-
glutKeyboardFunc(keyboard);
-
glutMouseFunc(mouse);
-
glutMotionFunc(motion);
-
glutIdleFunc(idle);
-
-
glutMainLoop();
-
-
return(0);
-
}
-
-
void display(void)
-
{
-
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
-
-
glMatrixMode(GL_MODELVIEW);
-
glPushMatrix();
-
-
glTranslatef(0.f, 0.f, Zoom);
-
-
glRotatef(Xrot, 1.f, 0.f, 0.f);
-
glRotatef(Yrot, 0.f, 1.f, 0.f);
-
glRotatef(Zrot, 0.f, 0.f, 1.f);
-
-
RenderGameBoard(GL_RENDER);
-
-
glPopMatrix();
-
-
glutSwapBuffers();
-
}
-
-
void reshape(int w, int h)
-
{
-
glViewport(0, 0, w, h);
-
glMatrixMode(GL_PROJECTION);
-
glLoadIdentity();
-
gluPerspective(60.f, GLfloat(w) / GLfloat(h), 1.f, 1000.f);
-
glMatrixMode(GL_MODELVIEW);
-
}
-
-
void mouse(int button, int state, int x, int y)
-
{
-
switch(state)
-
{
-
case GLUT_UP:
-
{
-
break;
-
}
-
case GLUT_DOWN:
-
{
-
Xmouse = x;
-
Ymouse = y;
-
-
switch(button)
-
{
-
case GLUT_LEFT_BUTTON:
-
{
-
CompletePendingMove();
-
-
Node *N = PickNode(x, y);
-
-
if(!N || N == SelectedNode)
-
{
-
SelectedNode = 0;
-
}
-
else if(MakeMove(SelectedNode, N))
-
{
-
JumpingNode = SelectedNode;
-
SelectedNode = 0;
-
}
-
else
-
{
-
SelectedNode = N;
-
}
-
-
break;
-
}
-
case GLUT_RIGHT_BUTTON:
-
{
-
break;
-
}
-
}
-
-
break;
-
}
-
}
-
-
glutPostRedisplay();
-
}
-
-
void motion(int x, int y)
-
{
-
Xrot += GLfloat(y - Ymouse);
-
Zrot += GLfloat(x - Xmouse);
-
-
Ymouse = y;
-
Xmouse = x;
-
-
glutPostRedisplay();
-
}
-
-
void keyboard(unsigned char key, int x, int y)
-
{
-
switch(key)
-
{
-
case '[':
-
{
-
Zoom -= 1.2f;
-
break;
-
}
-
case ']':
-
{
-
Zoom += 1.2f;
-
break;
-
}
-
}
-
-
glutPostRedisplay();
-
}
-
-
void idle(void)
-
{
-
AnimateMovingMarbles();
-
-
glutPostRedisplay();
-
}
-
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
thank you, I tried it, but there's no difference. 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.
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
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 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.
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
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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:
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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
|
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.
|
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.
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |