Visual Studio 2013 C ++ link static library glew, glfw in virtual machine

I am unable to link static libraries in a C ++ visual studio 2013 project.

  • I downloaded the latest glew-1.11.0-win32 and glfw-3.1.1.bin.WIN32
  • Set path to include directory (Project Properties> C / C ++ "Additional Include Directories")

    C:\Users\User\Documents\Visual Studio 2013\Projects\OpenGL\OpenGL\Common
    
          

  • Add path to lib files (Project Properties> Linker> General "Additional library directories")

    C:\Users\User\Documents\Visual Studio 2013\Projects\OpenGL\OpenGL\Common\Libs
    
          

  • Add library names (Project Properties> Linker> Input "Additional Dependencies")

    glew32.lib
    glfw3.lib
    
          

  • Define a preprocessor GLEW_STATIC (it shows up when I remove this)

    (project Properties > C/C++ > Preprocessor "Preprocessor Definitions")
    
          

When I build my project the following error occurs:

Error   1   error LNK2001: unresolved external symbol _glewExperimental C:\Users\User\documents\visual studio 2013\Projects\OpenGL\OpenGL\Source.obj    OpenGL
Error   2   error LNK1120: 1 unresolved externals   C:\Users\User\documents\visual studio 2013\Projects\OpenGL\Debug\OpenGL.exe OpenGL

      

When I want to complete this

#include<Windows.h>


#include<GL\glew.h>
#include<GLFW\glfw3.h>

#include<iostream>

GLFWwindow * window;

using namespace std; 

int main()
{
    glewExperimental = TRUE;
    GLenum error = glewInit();
    if (error != GLEW_OK)
    {
        cout << "Error!" << endl;
    }

    system("pause");

    return 0;
}

      

Windows 8.1 in a virtual machine (VirtualBox) and Mirosoft Visual Studio 2013

What am I doing wrong? Elsewhere in this forum, this solution works correctly.

When I remove these two libraries from the directories, I get the same error, so maybe Visual is not seeing these two libraries. But the path is set correctly. Include path works, all header files are visible to intelsense.

+3


source to share


1 answer


@bogdan is correct: static version of GLEW library glew32s.lib .

BTW, the GLEW installation page on sourceforge.net says that you should include glew.h and glew.c in your project if you need static linking. "While this sounds simple enough, it seemed like unnecessary rudeness for every openGL project Instead, do the following:

  • Add GLEW_STATIC macro in properties - General properties - C / C ++ - Preprocessor - Preprocessor definitions
  • Add glew32s.lib in Properties - General Properties - Linker - Input - Additional Library Dependencies
  • If you haven't copied glew32s.lib to one of the default Visual Studio library paths, add the path to it under Properties - General Properties - Linker - General - Additional Libraries


Worked for me.

If you are not aware of this, you can Add a new property sheet for example. openglPropertySheet32Static, in Property Manager (View menu - Other Windows - Property Manager). Add your openGL specific properties to it. Remember to explicitly save the sheet - I'm not sure if it is automatically saved with the project. Then all you have to do for future openGL projects is Add an existing property sheet , openglPropertySheet32Static, in the property manager (you remember where you saved it, right?).

+2


source







All Articles