0

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

DorkMonstuh
  • 819
  • 2
  • 19
  • 38

2 Answers2

2

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:

  1. Dynamic (glew32)
  2. Dynamic multi-context (glew32mx)
  3. Static (glew32s)
  4. 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"
Community
  • 1
  • 1
Andon M. Coleman
  • 42,359
  • 2
  • 81
  • 106
  • 1
    Hi @Andon I carried out what you said however I still got the same error – DorkMonstuh Jun 12 '14 at 02:18
  • Did you remove the 4 different GLEW libraries you had as dependencies originally? They will create symbol collisions if you really try to link to all 4. – Andon M. Coleman Jun 12 '14 at 02:20
  • I left glew32s within the dependencies but removed the others. Should I also remove glew32s? I also added the code you mentioned above just now but that didn't solve either – DorkMonstuh Jun 12 '14 at 02:23
  • Yes, and do not put the headers or libraries in MSVC's directories. Put them in a directory relative to your project's root directory. I use `/platform/OpenGL/glew32s.lib` and `/platform/OpenGL/glew.h` in my own software. In MSVC, I have `#pragma comment (lib, "platform/OpenGL/glew32s.lib")` and `#include "platform/OpenGL/glew.h"`. You can use any convention you want, but that is what I use to store platform/subsystem specific headers and libraries without requiring extra installation steps that modify your installation of MSVC. – Andon M. Coleman Jun 12 '14 at 02:28
  • I'll give this a go, it's just I was following the second suggestion in this post. I did it with glut but did not seem to work with glew http://stackoverflow.com/questions/12171317/how-do-you-install-glut-and-opengl-in-visual-studio-2012 – DorkMonstuh Jun 12 '14 at 02:31
  • In fact, I found an old answer I wrote that outlines the process I use [here](http://stackoverflow.com/questions/20873321/visual-studio-2012-error-lnk1104-cannot-open-file-glew32-lib/20873711#20873711). That might help you. – Andon M. Coleman Jun 12 '14 at 02:34
  • You're a goddamn hero, adding those 3 lines of code into my header file MADE IT WORK. What a fcking drag this is, honestly. But thanks for saving me the headache – Aleksas Feb 16 '22 at 12:18
1

I found the solution to this problem here:

  • Include Header files:

    1. Right click on your project > Properties > Configuration > C/C++ > General > Additional Include Directories
    2. On the right dropdown, click <Edit...>
    3. Additional Inclue Directories has appeared
    4. Click the new line icon > browse button then select the glew include folder: $(your path to glew)\glew-1.12.0\include
  • Include Libraries

    1. Right click on your project > Properties > Configuratio Properties > Linker > General > Additional Library Directories
    2. Click <Edit...>
    3. Additional Library Directories has appeared
    4. For the 64-bit version: add $(your path to glew)\glew-1.12.0\lib\Release\x64
    5. For 32-bit version: add $(your path to glew)\glew-1.12.0\lib\Release\Win32
    6. Right click on your project (again) >Properties > Configuration Properties > Linker > Input > Additional Dependencies
    7. Click <Edit..>
    8. Additional Dependencies window has appeared
    9. Click the white area and write glew32.lib
A-Sharabiani
  • 17,750
  • 17
  • 113
  • 128