PDA

View Full Version : Error in VC++6.0



JLawson
08-04-2001, 02:14 PM
Okay, I'm just trying to build a simple little program, but I keep getting this same error. I also get these same errors everytime I try to compile any openGL .cpp file.

The file below compiles fine, with no errors/warnings, but when I click build (in MSVC++6.0) I get the errors.

Heres the errors (exactly as they appear):




--------------------Configuration: openGL1 - Win32 Debug--------------------
Linking...
glut32.lib : warning LNK4003: invalid library format; library ignored
glut32.lib : warning LNK4003: invalid library format; library ignored
openGL1.obj : error LNK2001: unresolved external symbol _glutMainLoop@0
openGL1.obj : error LNK2001: unresolved external symbol _glutMouseFunc@4
openGL1.obj : error LNK2001: unresolved external symbol _glutReshapeFunc@4
openGL1.obj : error LNK2001: unresolved external symbol _glutDisplayFunc@4
openGL1.obj : error LNK2001: unresolved external symbol _glutCreateWindow@4
openGL1.obj : error LNK2001: unresolved external symbol _glutInitWindowSize@8
openGL1.obj : error LNK2001: unresolved external symbol _glutInitWindowPosition@8
openGL1.obj : error LNK2001: unresolved external symbol _glutInitDisplayMode@4
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/openGL1.exe : fatal error LNK1120: 9 unresolved externals
Error executing link.exe.

openGL1.exe - 10 error(s), 2 warning(s)


Please take a look at my code too, just to make sure that I am doing it right =)




#include <E:/vc98/include/STDAFX.h>
#include <E:/vc98/include/gl/glut.h>

bool Init(void);

void Display(void);

void Reshape(int Width, int Height);

void Mouse(int Button, int State, int x, int y);

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmpLine, int nCmdShow) {

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);

glutInitWindowPosition(50,50);

glutInitWindowSize(640,480);

glutCreateWindow("Window Title!");

Init();

glutDisplayFunc(Display);

glutReshapeFunc(Reshape);

glutMouseFunc(Mouse);

glutMainLoop();

return 0;

}

bool Init(void) {
return true;
}

void Display(void) {
}

void Reshape(int Width, int Height) {
}

void Mouse(int Button, int State, int x, int y) {
}



I'd appreciate any help. =)

P.S. If your gonna try and tell me that the #include directory should be different, you better have a good explanation, cause It works just fine the way it is.

08-04-2001, 04:04 PM
Well, I'm not sure about your error, but I am sure about one thing: There is a very good reason for changing the way you write your #includes. If you ever give your code to anyone else, they will not be able to compile it unless they have MSVC and the directory happens to be E:/vc98/. And actually, I think I do know the answer to your problem: The version of glut32.lib that you are trying to link with is in a format unsupported by MSVC, and so you get all the errors below. One possibility is that you have libraries compiled for a different platform. In any case, you should probably get a new version of GLUT, or at least try to work without GLUT.

lobstah
08-04-2001, 04:43 PM
Hi,
You may want to check the linking of libraries. Strike the key chord Alt + F7 and click on the link tab; ensure that you have added the necessary OGL libraries. If you have added them, make sure they are located in the lib folder for MVS (this is were I put mine).

Good Luck.

Lobstah...



Originally posted by JLawson:
Okay, I'm just trying to build a simple little program, but I keep getting this same error. I also get these same errors everytime I try to compile any openGL .cpp file.

The file below compiles fine, with no errors/warnings, but when I click build (in MSVC++6.0) I get the errors.

Heres the errors (exactly as they appear):

[CODE]

JLawson
08-04-2001, 04:49 PM
Boy that was really stupid of me. I cant believe I forgot. I was using Borland C++ 3.1 for a long time and had the borland lib's, and forgot to goto MSVC..ANYWAY!!!

Now that that is done, I still have errors. Now, They are:




--------------------Configuration: openGL1 - Win32 Debug--------------------
Linking...
openGL1.obj : error LNK2001: unresolved external symbol ___glutCreateWindowWithExit@8
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/openGL1.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

openGL1.exe - 3 error(s), 0 warning(s)


I dont get why Im getting these friggin errors! Help!

ffish
08-04-2001, 08:02 PM
Programs that use GLUT are normally console programs, with a main instead of a WinMain. I tried a while ago to find a way around this, with tips from someone else on this board, but I never quite got it to work. The settings I had caused Blue Screens of Death.

With the first error, check glut.h for glutCreateWindowWithExit and make sure it is in there. If not, don't use it http://www.opengl.org/discussion_boards/ubb/wink.gif

Hope that helps.

JLawson
08-04-2001, 08:13 PM
ACK! Nothing wants to work!!! glutCreateWindowWithExit is there... And I'm still getting the errors!! Someone just give some random suggestions please. I'm using MSVC++6.0.... cout<<"PLEASE\nHELP!!!";

ffish
08-04-2001, 11:50 PM
Did you try changing WinMain to main? You will encounter problems if you try to use WinMain and GLUT.

lobstah
08-05-2001, 03:07 AM
Here are the includes for my opengl program:

#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <malloc.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include <gl\glut.h>
#include <math.h>
#include <time.h>
#include "resource.h"
#include "GLCode.c"
#include "WINglobals.c"
#include "AboutDlgProc.c"

Here the link list:

opengl32.lib glu32.lib glaux.lib

Hope this helps in someway.

Good Luck.

Lobstah.

V--man
08-05-2001, 05:02 AM
Why do so many newbies use glaux? There are much better libraries out there for doing the things glaux does. Besides, support for aux is dropped.

V-man

Spartacus
08-05-2001, 05:38 AM
Try adding:
#define GLUT_DISABLE_ATEXIT_HACK

That should work.

There is also some stuff written about this in glut header file.

JLawson
08-05-2001, 07:26 AM
ACK!! Still have the same errors. I have tried everything posted so far, and nothing works! Im new to VC++6.0, but not to C++, and I am a fast learner, so VC++ is coming fast. OGL looks really fun by the tutorials and programs that I have downloaded so far, but I cant do anything until I get it to work! Are there some settings that I am not setting up properly? Please, all you people with VC++6.0, just shout out some of the standard things that you need to have openGL build properly...THANKS!

JLawson
08-05-2001, 07:37 AM
Okay, I have added

#define GLUT_DISABLE_ATEXIT_HACK

to my glut.h file, which reduced my errors to




--------------------Configuration: openGL1 - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/openGL1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

openGL1.exe - 2 error(s), 0 warning(s)


Anyone else ever get those errors before? I have no clue why I am getting them. Help???

JLawson
08-05-2001, 08:32 AM
For the record, here again is the code I am trying to build (it compiles just fine):

#include "E:\vc98\include\stdafx.h"
#include <E:\vc98\include\gl\glut.h>

bool Init(void);
void Display(void);
void Reshape(int Width, int Height);
void Mouse(int Button, int State, int x, int y);

int Main() {

glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
glutInitWindowPosition(50,50);
glutInitWindowSize(640,480);
glutCreateWindow("Window Title!");

Init();

glutDisplayFunc(Display);

glutReshapeFunc(Reshape);

glutMouseFunc(Mouse);

glutMainLoop();

return 0;

}

bool Init(void) {
return true;
}

void Display(void) {
}

void Reshape(int Width, int Height) {
}
void Mouse(int Button, int State, int x, int y) {

}

Korval
08-05-2001, 08:34 AM
When you created this VC++ project, did you ask for a Win32 console application or a Win32 Application? If you asked for a console app, then you did the right thing. If you asked for just an application, then you will need to create a new Win32 Console application.

JLawson
08-05-2001, 08:59 AM
Heres something interesting... Yes, it is a console application... And just to make sure, I recreated another project. This time, when I went to build it, the only error was

--------------------Configuration: test - Win32 Debug--------------------
Linking...
LINK : fatal error LNK1104: cannot open file "glut32.lib"
Error executing link.exe.

test.exe - 1 error(s), 0 warning(s)


Now, obviously the solution to that is to give it glut32.lib... But when I give it glut23.lib, I get the following error:

--------------------Configuration: test - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

test.exe - 2 error(s), 0 warning(s)


It looks to me like theres an error in glut32.lib... But Im not that experienced with OGL, so what do you guys think?


By the way, I do have opengl32.lib, glut32.lib, and glaux.lib(just incase) if you wanted to know.

richardve
08-05-2001, 10:43 AM
JLawson,

Try using:



int main()

instead of:



int Main()

Watch the uppercase "M", the real main() is with a lowercase "m"

JLawson
08-05-2001, 11:17 AM
oh my god...oh my dear, dear god...I have been programming for 4 years now, and I didnt have "main" cased properly? I swear, if brains was gas, I wouldnt have enough to power an ants motor scooter around the outside edge of a dime!! THANK YOU ALL FOR YOUR HELP! I REALLY APPRECIATE IT...I DONT THINK I COULD BE WHERE i AM TODAY WITHOUT THE HELP OF PPL LIKE YOU GUYS!!! THANKS AGAIN!!!!


PS

i didnt lowercase the "m" in "Main".....
Boy, I feel stupid....