Linking Errors

Here is my code

#include <gl/glut.h>
#include <gl/gl.h>

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);//clear anything that is in the buffer
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
}

void main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“3D Tech- GLUT Tutorial”);
glutDisplayFunc(renderScene);
glutMainLoop();
}

Here is my errors:

Linking…
LIBCD.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16
Debug/myfirstprog.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

I have added the opengl32.lib files and the other ones too…

have gone to projects settings link and placed the wWinMainCRTStartup under the entry point symbol…

Tried removing wWinMain… and making line 16 WinMain(…w/ the correct arguments) but no luck either I get the following errors:

C:\Program Files\Microsoft Visual Studio\MyProjects\myfirstprog\myprog.cpp(18) : warning C4007: ‘WinMain’ : must be ‘__stdcall’
C:\Program Files\Microsoft Visual Studio\MyProjects\myfirstprog\myprog.cpp(18) : error C2731: ‘WinMain’ : function cannot be overloaded
C:\Program Files\Microsoft Visual Studio\MyProjects\myfirstprog\myprog.cpp(18) : see declaration of ‘WinMain’
C:\Program Files\Microsoft Visual Studio\MyProjects\myfirstprog\myprog.cpp(19) : error C2664: ‘glutInit’ : cannot convert parameter 2 from ‘char *’ to 'char ** ’
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

and still not working…any suggestions here. Thank in advance for yourhelp.

Sincerely,

Joe

I always link against these libraries and never ran into errors (I ommit glut)

#pragma comment(lib, “opengl32.lib”)
#pragma comment(lib, “glu32.lib”)
#pragma comment(lib, “gdi32.lib”)

try to set the app type to “dos application”.
although it’s obviously an app with windows, the type “void main” is allowed only for dos, not for windows (for which the compiler expects a “WinMain”).

i had the same problem too. i tried to write a windows application. so it asks for Win Main(). if you try to run this as Win32 console application in Visual C++ and link opengl32.lib, glut32.lib and glu32.lib there wont be any problems.

Isn’t that only linking with the non *32 libs (like glut.lib instead of glut32.lib) would be suffisant ?

I don’t remember thought.

Thank you all for the replies.
I am not sure what this meant to be

#pragma comment(lib, “opengl32.lib”)
#pragma comment(lib, “glu32.lib”)
#pragma comment(lib, “gdi32.lib”)

is that a substitute for my #include?

I had linked the glu32.lib, glut32.lib, and opengl32.lib. Those cleared out a lot of errors, and left me at the point where I am at right now.

Well right now I am having the header file problem.

#include “gl/glut.h”
#include “gl/gl.h”

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);//clear anything that is in the buffer
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
}

void main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“3D Tech- GLUT Tutorial”);
glutDisplayFunc(renderScene);
glutMainLoop();
}

I get this error,

: fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
Can someone help me out here? I really need to get OpenGL going on my machine. I am wondering if you someone would be willing do remote login to my box to help me out. I usually use VNC remote login. If you could set up a time or let me know if you are willing to and I would give you the info. Thanks a bunch again guys.

Joe

#pragma comment(lib, “opengl32.lib”)
#pragma comment(lib, “glu32.lib”)
#pragma comment(lib, “gdi32.lib”)

is that a substitute for my #include?
when you use pragma comment, it tells to link these libraries, when you use #include it tells to compile using these headers.
Using pragma comment instead of visual studio linker settings. You need to add libraries to the linker, and headers to preprocessor

Take a look here

 #include "gl/glut.h"
#include "gl/gl.h" 

using “” means that these headers are in your local path (near the project files, .i.e .cpp .vcproj etc…)
So the preprocessor is searching in path_project/gl/header.h
using <> instead “” means that these headers are in the compiler headers path

hope that helps

Alright,

somehow it worked. I pulled out one of my sample/testing .cpp file and added a default project, added the opengl, glut and glu .libs and it worked… I think it was the way I am selecting the features for my project. It had to be win32 instead of win32 console application If anyone has an input here please let me know…

Thank you all.

Joe