I have tried everything! I even downloaded NeHe''s Lesson 1 for Open GL, but when I compile even HIS source code I get two error linking messages.
One says: error LNK2001: unresolved external symbol _main
And the other says: fatal error LNK1120: 1 unresolved externals
I have linked the Open GL libraries to my program (I double-checked, yes, I linked all three) Please help!!!
Help, Please!!! It won't work!
Started by Blender Boy, Aug 05 2001 04:31 AM
6 replies to this topic
Ad:
#3 Moderators - Reputation: 1315
Posted 05 August 2001 - 05:20 AM
Also, you can just use NeHe''s included project and workspace files, so you can just compile it right off the bat.
------------------------------
Trent (ShiningKnight)
E-mail me
Shining Darkness- A division of Chromesphere Studios
------------------------------
Trent (ShiningKnight)
E-mail me
Shining Darkness- A division of Chromesphere Studios
#6 Members - Reputation: 142
Posted 10 August 2001 - 09:55 AM
Go to Project->Settings. Under the "Link" tab there is a text box labeled "Project Options." Somewhere in it, you'll find the text "/subsystem:console" although you really want it to read "/subsystem:windows" because you're making a Windows program. Change that and it will work.
Edited by - TerranFury on August 10, 2001 4:57:56 PM
Edited by - TerranFury on August 10, 2001 4:57:56 PM
#7 Members - Reputation: 122
Posted 10 August 2001 - 02:55 PM
I''m a bit bored, so I''ll sum up everything thats been said so far in easy terms.
------------------------------------------------
Project Type Differences
------------------------------------------------
There''s two [main] kinds of projects you can make in VC++:
Win32 Console Application
It''s like the old-style C++ (you know, using printf() and cout)]
It runs in DOS and you cant use any of the stuff from Windows [like graphics/etc].
Win32 Application
This is the one you want. This one runs under windows, not DOS. You can do all the stuff with the Windows API/OpenGL here.
------------------------------------------------
Startup Function Differences
------------------------------------------------
Win32 Console Application
The startup function used in the DOS app is this:
int main();
Win32 Application
The startup function used here is this:
int WINAPI WinMain(....);
------------------------------------------------
Libraries
------------------------------------------------
OpenGL''s libraries are not included in the VC++ default project settings. You must put them there yourself.
There are two ways to do this under VC++.
One is in the Project menu, under Settings. In one of the tabs there somewhere [I can''t remember off the top of my head, I think its under ''Link''] is a textbox that has a bunch of libraries listed under it. Add to the end of that list the following:
OpenGL32.lib GLu32.lib GLaux.lib
The other method I like better myself, because you dont need to add those libraries to the Link Settings every time you make a new OpenGL project. With this method, you add the libraries directly in your source code. However, there are portability issues, but at this stage in development, no one cares.
Just go to the very first line in your program [above the includes] and add the following lines:
#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "GLu32.lib")
#pragma comment(lib, "GLaux32.lib")
[As a small note, make sure these libraries exist on you machine in C:\windows\system\, or else either method wont work]
------------------------------------------------
Summary
------------------------------------------------
If you''re getting a message about UNRESOLVED SYMBOL MAIN(), then you have created a Win32 Console Application. You need to create a Win32 Application, not Console.
Repeat: Create a
WIN32 APPLICATION
not
WIN32 CONSOLE APPLICATION
With the libraries, including just the header files for OpenGL is not enough, you have to manually include the libraries for OpenGL
------------------------------------------------
Anyway, as you can see I was bored, but I hope this helps you out.
------------------------------------------------
Project Type Differences
------------------------------------------------
There''s two [main] kinds of projects you can make in VC++:
Win32 Console Application
It''s like the old-style C++ (you know, using printf() and cout)]
It runs in DOS and you cant use any of the stuff from Windows [like graphics/etc].
Win32 Application
This is the one you want. This one runs under windows, not DOS. You can do all the stuff with the Windows API/OpenGL here.
------------------------------------------------
Startup Function Differences
------------------------------------------------
Win32 Console Application
The startup function used in the DOS app is this:
int main();
Win32 Application
The startup function used here is this:
int WINAPI WinMain(....);
------------------------------------------------
Libraries
------------------------------------------------
OpenGL''s libraries are not included in the VC++ default project settings. You must put them there yourself.
There are two ways to do this under VC++.
One is in the Project menu, under Settings. In one of the tabs there somewhere [I can''t remember off the top of my head, I think its under ''Link''] is a textbox that has a bunch of libraries listed under it. Add to the end of that list the following:
OpenGL32.lib GLu32.lib GLaux.lib
The other method I like better myself, because you dont need to add those libraries to the Link Settings every time you make a new OpenGL project. With this method, you add the libraries directly in your source code. However, there are portability issues, but at this stage in development, no one cares.
Just go to the very first line in your program [above the includes] and add the following lines:
#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "GLu32.lib")
#pragma comment(lib, "GLaux32.lib")
[As a small note, make sure these libraries exist on you machine in C:\windows\system\, or else either method wont work]
------------------------------------------------
Summary
------------------------------------------------
If you''re getting a message about UNRESOLVED SYMBOL MAIN(), then you have created a Win32 Console Application. You need to create a Win32 Application, not Console.
Repeat: Create a
WIN32 APPLICATION
not
WIN32 CONSOLE APPLICATION
With the libraries, including just the header files for OpenGL is not enough, you have to manually include the libraries for OpenGL
------------------------------------------------
Anyway, as you can see I was bored, but I hope this helps you out.






