Error in VC++6.0

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.

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.

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:
[b]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):

[/b]

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!

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

Hope that helps.

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
HELP!!!”;

Did you try changing WinMain to main? You will encounter problems if you try to use WinMain and GLUT.

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.

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

Try adding:
#define GLUT_DISABLE_ATEXIT_HACK

That should work.

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

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!

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???

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) {

}

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.

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.

JLawson,

Try using:

int main()

instead of:

int Main()

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

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…