OpenGL and Linking Problems...

Started by
5 comments, last by smm RaGe 20 years, 6 months ago
Alright.. I was following the tutorials (I''m a newbie, so I started with the first ;P). It compiles fine.. but when it when it starts to build (link) it screws up. It says: --------------------Configuration: Lesson1 - Win32 Debug-------------------- 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__glEnd@0 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glBegin@4 Lesson1.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12 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: 19 unresolved externals Error executing link.exe. Lesson1.exe - 20 error(s), 0 warning(s) I even downloaded the source code that NeHe made, and I can''t get it to work. Any suggestions would be very appreciated. Immune you say ..yet venom strikes.. ....in strangest guises....
Immune you say..yet venom strikes......in strangest guises....
Advertisement
Okey. I went looking around on the net, and found a solution. IF ANYONE ELSE HAS THIS PROBLEM, SIMPLY DO THE FOLLOWING:

add:
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

before the #includes.

Immune you say
..yet venom strikes..
....in strangest guises....
Immune you say..yet venom strikes......in strangest guises....
yeah those 2 lines just add those lib files to your project. the libs contain the opengl functions (e.g. glVertex3f). you can also add them directly to your project (if you''re using MSVC) by going to your project settings and adding them in under your Link tab.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
I have the same problem and it doesn''t disappear. Here is what i have:
inking...
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/shit.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

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

I linked needed .lib files but it didn''t help me...
quote:Original post by Anonymous Poster
I have the same problem and it doesn''t disappear. Here is what i have:
inking...
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/shit.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

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

I linked needed .lib files but it didn''t help me...


That''s because you don''t have an entry point for your application.

If it''s a console application add this:
int main(int argc, char* argv[]){    return 0;}


If it''s a Win32 application add this:
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){    return 0;}


-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"
you''re getting that error because you don''t have a main function in your project. all exes must have a main function.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
the "LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main" error usually means that MSVC messed up in a multi-file project. In your fileview, check settings on every .CPP and .H file, going to the general tab and see if you exclude them from your build (default behaviour for MSVC if you add files to project for some nut-case reason).

-- Xeno Zohar
"They all look the same. Let''s start hitting some buttons."

This topic is closed to new replies.

Advertisement