LINKING PROPLEM LEASON 1

Started by
4 comments, last by _the_phantom_ 18 years, 5 months ago
I try to compile leason 1 on VC++ 6 and the fallowing happen Compiling... Lesson1.cpp Linking... Lesson1.obj : error LNK2001: unresolved external symbol _gluPerspective@32 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glViewport@16 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glHint@8 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glDepthFunc@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glEnable@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glClear@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8 Lesson1.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4 LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Lesson1.exe : fatal error LNK1120: 15 unresolved externals Error executing link.exe. Results Lesson1.exe - 16 error(s), 0 warning(s) and i read in some thread that i should do #pragma comment( lib, "opengl32.lib" ) #pragma comment( lib, "glu32.lib" ) #pragma comment( lib, "vfw32.lib" ) but still Output Window Compiling... Lesson1.cpp Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/Lesson1.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Results Lesson1.exe - 2 error(s), 0 warning(s) PLEASE HELP
Advertisement
Hey bud,

The cause of this error:

error LNK2001: unresolved external symbol _main

is likely because you have created a new project set up for a console application, one where you have int main( int argc, char* argv[] ). But instead you either don't have that main or you have the WIN32 main, which is different. Now in Visual Studio if you go to the project options/settings and look at the Link->System tab there is an option called subsystem that allows you to choose what style of build to use. Change it to console.

Hope that helps,

ace
If you are using WinMain, make sure you have #include <windows.h>
Sorry... but I just got to say it.

Linking Proplem Leason 1.


lol. :)

Sorry if I'm being rude, but I see this crazy chinese guy in my head when I'm reading that sentence...


Peace!
"Game Maker For Life, probably never professional thou." =)
No, I really don't consider that rude, I consider that a wakeup call. Anyone who gets a linking problem as specific as the one above, and doesn't know what it means is clearly starting to program with opengl, instead of learning programming and then learning the OpenGL API. In my opinion, this is an impatient and unwise way to do things. Personally, I think people should learn all the basics first rather than copy and pasting code from something clearly above their head and hoping it works.

Also, I think it would be wise for people to actually think when reading errors.
Lets look at this one example: "Lesson1.obj : error LNK2001: unresolved external symbol _gluPerspective@32" Well, from that error, we can gather three things, one is that something is unresolved (doesn't exist) another is that it is the function gluPerspective that doesn't exist, and lastly that this is a problem with the linking stage of the compiler. I think it is pretty obvious that you aren't include the library that contains the gluPerspective function from that.

I am not trying to be mean to newbies or anything of that sort, I just think that they would be alot better off if they started with the basics, and worked their way up to things more complex.
- relpats_eht
cross posted and as its NeHe related amd this was posted 2nd I'm closing this one.

This topic is closed to new replies.

Advertisement