Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems linking GLEW with Visual Studios

I have tried several ways to get GLEW working with my VS2010 project. No success. At first I tried using the pre-built libs and dlls from the website. I downloaded these pre-built files from http://glew.sourceforge.net/index.html and did something like: setting up GLEW windows?

  1. .h files were put in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include

  2. .lib files were put in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64 (I also put them one level up just in case)

  3. glew32.dll went to C:\Windows\SysWOW64

  4. linker->input add glew32.lib, GlU32.lib, and OpenGL32.lib to Additional Dependencies

  5. Preprocessor definitions: put in GLEW_BUILD and GLEW_STATIC (my program needs to be a DLL but other seem to have success with the STATIC one, so I include both)

When I run the program with these settings, glewInit() is not so GLEW_OK. Even though glewInit() fails, it still recognizes that function strangely. When I use another glew function like "glCreateProgram()", I get the following errors:

Error   56  error LNK2020: unresolved token (0A000327) __glewCreateProgram  
C:\Users\aab\studyWrist\Visualization\libCoin3D\ShaderHandler.obj   libCoin3D

Error   57  error LNK2001: unresolved external symbol __glewCreateProgram   
C:\Users\aab\studyWrist\Visualization\libCoin3D\ShaderHandler.obj   libCoin3D

Error   58  error LNK1120: 2 unresolved externals   
C:\Users\aab\studyWrist\Visualization\libCoin3D\Debug\libCoin3D.dll libCoin3D

So, some other suggestions on stackoverflow are to rebuild glew. So next I tried building glew32d in VS2010. I followed OpenGL: How to compile glew32.dll from source file and got glew32d.dll and glew32d.lib.

  1. glew32d.lib put in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64 (the program only recognizes the lib if i put it in x64 folder, and not a level up)

  2. glew32d.dll went to C:\Windows\SysWOW64

  3. linker->input add glew32d.lib (this one is changed), GlU32.lib, and OpenGL32.lib to Additional Dependencies

  4. Preprocessor definitions: put in GLEW_BUILD and GLEW_STATIC

My following errors are caused just by glewInit:

Error   56  error LNK2028: unresolved token (0A000383) "extern "C" unsigned int 
__cdecl glewInit(void)" (?glewInit@@$$J0YAIXZ) referenced in function "public: __cdecl 
MasterCube::MasterCube(void)" (??0MasterCube@@$$FQEAA@XZ)   
 C:\Users\aab\studyWrist\Visualization\libCoin3D\MasterCube.obj libCoin3D

Error   57  error LNK2019: unresolved external symbol "extern "C" unsigned int 
__cdecl glewInit(void)" (?glewInit@@$$J0YAIXZ) referenced in function "public: __cdecl 
MasterCube::MasterCube(void)" (??0MasterCube@@$$FQEAA@XZ)   
C:\Users\aab\wristuptodate\studyWrist\Visualization\libCoin3D\MasterCube.obj    
libCoin3D

Any idea what's going wrong and how I can fix it?

like image 357
AAB Avatar asked Dec 27 '22 03:12

AAB


1 Answers

Don't add them into system directories. You should not be throwing things into system directories. Or the MSVC directories. You should have your own place somewhere on your drive for these things, lest you accidentally break things. You tell your tools i.e Visual Studio where to find your library, instead of putting your library in the tools i.e visual studio directories. You can keep your library within the project directories. You can follow the following sets to setup GLEW I assume you have created VC++ win32 console application project.

step 1. Create the directory in project directory lets assume directory name is "thirdparty"

step 2. copy and past the glew-1.9.0 library folder in directory thirdparty

step 3. Now goto the Menu Project->(projectName)properties.. or press Alt + F7. You will see project properties window.

step 4. goto Congiguration Properties-> VC++ Directories option. From there on right side give the path of glew library. In Include Directories give path: $(ProjectDir)thirdparty\glew-1.9.0\include; In Library Directories give path: $(ProjectDir)thirdparty\glew-1.9.0\lib;

Now follow follow last step for linking.

step 5. goto linker->Input option. Link glew32.dll.In Additional Dependencies: glew32.dll;

like image 104
Dinesh Subedi Avatar answered Feb 22 '23 13:02

Dinesh Subedi