Linker errors in Visual C++ 2010

Started by
27 comments, last by tre 12 years, 11 months ago
[color="#FF0000"]This has been solved
The solution was first provided by abeylin (post #14).

Giving a direct "link" to the lib solved by problem. In this case I opted to change from #pragma comment to using the additional dependences in the project properties and added the full path to the .lib (in my case "d:/programming/libs/glew32.lib").

A big thanks to the people having helped me with this and made many things clearer for me (where to place lib's and why you can't place dll's in other folders than the project "root" or in the windows system folders.

Thanks for all the great help!
___________________________________

Hi all.
I've been trying for some time now to get GLEW to function correctly in VC++ 2010. I have no problems with this project in the older version i used to program in.
I get the following:
error LNK2001: unresolved external symbol __imp____wglewCreateContextAttribsARB
error LNK2019: unresolved external symbol __imp__wglewIsSupported referenced in function "public: bool __thiscall oglContext::create30Context(struct HWND__ *)" (?create30Context@oglContext@@QAE_NPAUHWND__@@@Z)
error LNK2019: unresolved external symbol __imp__glewInit referenced in function "public: bool __thiscall oglContext::create30Context(struct HWND__ *)" (?create30Context@oglContext@@QAE_NPAUHWND__@@@Z)


I know what an unresolved external symbol error is but this time I just don't know how to solve it.
When I compile my program. I've pragma commented the glew and opengl libraries in my main.h file:
#pragma once

// windowsfunktioner
#include <windows.h>

// input och output
#include <iostream>

// opengl och glew
#include <gl/glew.h>
#include <gl/wglew.h>
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "opengl32.lib")


Should the libs be located somewhere special? I mean other than the lib-folder in "Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"?

I've included this file in the header file used by the document that is giving these errors (opengl.h)
#include "main.h"

class oglContext {
public:
...


And this header file is included in the opengl.cpp file that is giving the errors.
I think the compiler is complaining about the following lines:
GLenum error = glewInit();

if(wglewIsSupported("WGL_ARB_create_context") == 1){
hrc = wglCreateContextAttribsARB(hdc, NULL, attributes);
...
}


I'm out of ideas. Do you guys know why I'm getting these errors?

Thanks,
Marcus Axelsson
Advertisement
Have you tried making a new project and copying the code in by hand there rather than transferring the project from the older version?

Have you tried making a new project and copying the code in by hand there rather than transferring the project from the older version?

Don't use pragma comment to include libs it's a lot easier if you do this in the project options and that way you won't run into problems when you add the pragma's in the wrong file. Left click your prject in the solution explorer en go to the linker section. In the linker section open go to input and then under additional dependencies you add the path to the library you need. This way the compiler will always know about what additional libs it needs to compile in.

If you ever switch to another compiler that won't support your #pragma comment(lib, ""), your code will no longer work properly. It's better to specify static libs on the command line then it is in code.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion


Have you tried making a new project and copying the code in by hand there rather than transferring the project from the older version?

Yep, I tried that. Did not work :/


Don't use pragma comment to include libs it's a lot easier if you do this in the project options and that way you won't run into problems when you add the pragma's in the wrong file. Left click your prject in the solution explorer en go to the linker section. In the linker section open go to input and then under additional dependencies you add the path to the library you need. This way the compiler will always know about what additional libs it needs to compile in.

If you ever switch to another compiler that won't support your #pragma comment(lib, ""), your code will no longer work properly. It's better to specify static libs on the command line then it is in code.



Allright, so I've removed my pragma comments and added the libraries to the project properties instead. This didn't change anything.



Thanks for your replies! I hope this can be fixed. I can't work on my project as it is now :/
Did you recompile glew for VS2010? I could be mistaken but I didn't think the libs were compatible across different versions of VC++.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

Did you recompile glew for VS2010? I could be mistaken but I didn't think the libs were compatible across different versions of VC++.


I've downloaded the most recent source and as I understand it, I'm supposed to use the "glew.dsw" in build/vc6. When I try to convert the project I get four error messages regarding the three project files. For example "'glew_shared.dsp' cannot be loaded". The same error message for all the projects.

So if I can't convert them... how am I going to compile them?

Sigh.
I had the same issue with that, a lot of VC6 projects don't convert directly to VC++2010. I was able to upgrade it by converting it first to vc++2008, and then converting that to vc++2010.

If you don't have both versions on hand and don't want to bother with it, you can use mine if you like. Its 1.5.7 which is a little older than the most recent, but it should be fine. If you want the latest version you'll have to convert it yourself.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

I had the same issue with that, a lot of VC6 projects don't convert directly to VC++2010. I was able to upgrade it by converting it first to vc++2008, and then converting that to vc++2010.

If you don't have both versions on hand and don't want to bother with it, you can use mine if you like. Its 1.5.7 which is a little older than the most recent, but it should be fine. If you want the latest version you'll have to convert it yourself.


Thanks! Will try this tomorrow. I'll report back.

Thanks again.
I tried using the files provided by karwosts, but it gave me the same issues (no matter how I tried to use them). So I'm still stuck.

Allright, so I've removed my pragma comments and added the libraries to the project properties instead.
[/quote]

What did you do exactly, in what menus?
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

This topic is closed to new replies.

Advertisement