问题
I have glew version 1.9.0 I have put all the header files in the MSVS include directory and all the lib files in the lib folder. I then put the dll within the sysWOW64 folder and have added all the libs needed in the additional dependencies under the project properties which are:
- opengl32.lib
- glu32.lib
- glut32.lib
- glew32.lib
- glew32mx.lib
- glew32s.lib
- glew32mxs.lib
However I am getting a linker error
Error 1 error LNK2019: unresolved external symbol _glewInit@0 referenced in function _main C:\Users\x\documents\visual studio 2013\Projects\openGLTest\openGLTest\main.obj openGLTest
回答1:
First, you should not place your DLLs into sysWOW64
or any other Operating System owned directory such as System32
. That said, this has nothing to do with where you placed your DLLs and everything to do with the library you linked to (or rather did not link to).
You also should not be linking to 4 different GLEW configurations:
- Dynamic (glew32)
- Dynamic multi-context (glew32mx)
- Static (glew32s)
- Static multi-context (glew32mxs)
The best library to link to usually is glew32s.lib
as it negates the need for the DLL in the first place, but then you need to add #define GLEW_STATIC
before you #include "glew.h"
In MSVC you can add the following to a source file to take care of all of these things at once:
#pragma comment (lib, "glew32s.lib")
#define GLEW_STATIC
#include "glew.h"
回答2:
I found the solution to this problem here:
Include Header files:
- Right click on your
project > Properties > Configuration > C/C++ > General > Additional Include Directories
- On the right dropdown, click
<Edit...>
Additional Inclue Directories
has appeared- Click the
new line icon > browse button
then select the glew include folder:$(your path to glew)\glew-1.12.0\include
- Right click on your
Include Libraries
- Right click on your project
> Properties > Configuratio Properties > Linker > General > Additional Library Directories
- Click
<Edit...>
Additional Library Directories
has appeared- For the 64-bit version: add
$(your path to glew)
\glew-1.12.0\lib\Release\x64 - For 32-bit version: add
$(your path to glew)\glew-1.12.0\lib\Release\Win32
- Right click on your project (again)
>Properties > Configuration Properties > Linker > Input > Additional Dependencies
- Click
<Edit..>
Additional Dependencies
window has appeared- Click the white area and write
glew32.lib
- Right click on your project
(Side Note: The accepted answer did NOT solve the problem)
来源:https://stackoverflow.com/questions/24175420/lnk2019-glewinit