Jump to content
  • Advertisement
Sign in to follow this  
marian42

OpenGL Problem with "Release" mode in Visual C++

This topic is 2478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

Im writing a tetris game with C++ using opengl.
I use MS Visual C++ 2010.
The program compiles succesfully in Debug mode but if I switch to Release I get a lot of compile errors like this:
(I apolgize that the error descritpions are in german, but its not possible to change the language in the settings.)


1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glLoadIdentity@0".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glTranslatef@12".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glRotatef@16".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glBegin@4".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glColor4f@16".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glVertex3f@12".
1>LooseBlock.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glEnd@0".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glViewport@16".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glMatrixMode@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_gluPerspective@32".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glShadeModel@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glClearColor@16".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glClearDepth@8".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glEnable@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glDepthFunc@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glHint@8".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glClear@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__wglMakeCurrent@8".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__wglDeleteContext@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__wglCreateContext@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glDisable@4".
1>main.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glBlendFunc@8".
1>TetrisGame.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glPointSize@4".
1>TetrisGame.obj : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__glColor3f@12".


The error message reads "unresolved external symbol".

I googled this problem and i think its about missing lib files, but i dont know where to put them and which files are required.

Share this post


Link to post
Share on other sites
Advertisement
Right Click The Solution select Properties then in the left hand tree expand Linker Select Inpt Add the required lib files in the Additional Dependencies field.
In the upper right of the window is a configuration dropdown, this is active, debug or both.

Alternativaley you could just pragma it in a file
[color="#666666"][font="monospace"]#pragma comment(lib, "opengl32.lib")[/font]
[color="#666666"]
Here is a minimal Win32 OpenGL window skeleton, the code should compile and run if you uncomment the pragma line.
http://pastebin.com/eKFWUhsP

Share this post


Link to post
Share on other sites

In the upper right of the window is a configuration dropdown, this is active, debug or both.

That was my problem. It was on active, not both.

Edit: Now I have another problem. Starting the program with VC++ works, but if i start the exe file from the Release folder, it instantly crashes.

Share this post


Link to post
Share on other sites
Copy the exe file in the same directory as your .vcproj file. Does it crash from here too? If not then it's dependant on something with a relative path (Perhaps a texture?) that you need to manually copy so it is relative to where the exe is.

Share this post


Link to post
Share on other sites
I didnt find a .vcproj, but a .vcxproj file. If i put the exe file in this directory, it still crashes.
My program does not use any files like textures, settings etc.

Share this post


Link to post
Share on other sites
A possible cause of this is a stray pointer. Debug builds under MSVC will initialize all local variables to known values, Release builds will not.

Share this post


Link to post
Share on other sites

Can you run the release exe from within visual studio?

I can select "Release" and then click the green triangle button next to it and it works.


A possible cause of this is a stray pointer. Debug builds under MSVC will initialize all local variables to known values, Release builds will not.


Im not sure if i understand what you mean. Doesnt MSVC interrupt the program and show an error message if I try to acces a pointer that is not initialized? In Debug mode the program runs without problems. I looked at the code and all variables are initialized in the contructor of the class. And i had a some error messages when I didnt initialize them, so i think there are no such things in my code.

Share this post


Link to post
Share on other sites
Im not sure if i understand what you mean. Doesnt MSVC interrupt the program and show an error message if I try to acces a pointer that is not initialized?


int x;
some_array[x];

Debug: x initialized to 0, so indexing is okay
Release: x uninitialized, takes some garbage value from memory which happens to be huge, so you try to access memory you don't own and the operating system kills you.

Now, this isn't exactly what happens (I think MSVC deliberately uses fairly large, easily noticed values like 0xCCCCCCCC and 0xBAADF00D) but you get the idea. On a side note: I don't think MSVC does do that (freeze and give an error message) at all - it's just that when you get an access violation, this will be trapped.

Share this post


Link to post
Share on other sites
I dont think that this is the problem because i commented out all the code so there is only a black window. But even this does only work from Visual Studio.
Maybe its important to say that I encounter the same problems wiht the exe file that is created in the Debug folder.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!