Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Linking error blowing my mind.

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    8

    Linking error blowing my mind.

    In the images below, I believe it is clear that I've properly linked what I need to. I am trying to build and run the program but it fails on these errors.
    Error 1 error LNK2019: unresolved external symbol _glewInit@0 referenced in function _main
    &
    Error 2 error LNK2001: unresolved external symbol _glewExperimental

    What else can I check for errors?

    Click image for larger version. 

Name:	ss+(2015-02-06+at+02.13.45).png 
Views:	132 
Size:	1.9 KB 
ID:	1623

    Click image for larger version. 

Name:	ss+(2015-02-06+at+02.12.45).jpg 
Views:	261 
Size:	20.0 KB 
ID:	1624


    I am using Visual Studio 2013. None of my code is underlined red in the editor.
    Code :
    // GLEW
    #define GLEW_STATIC
    #include <GL/glew.h>
    // GLFW
    #include <GLFW/glfw3.h>
     
    int main()
    {
    	glfwInit();
    	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);//version 3 ...
    	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);//... point 3
    	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);//what's a "core-profile" ? seriously
    	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);//this much is intuitive
     
    	GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", nullptr, nullptr); 
    	glfwMakeContextCurrent(window);
     
    	glewExperimental = GL_TRUE;
    	glewInit();
     
    	return 0;
    }

  2. #2
    Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    I can't read a thing in that screenshot, but according your linker errors, you are not inking against GLEW.
    You have to do more than setting up the library path, you also have to tell your IDE/buildsystem to link against
    the GLEW library.


    By the way, finding out what OpenGL(R) 3.1+ profiles (core and compatibillity) requires only a single google search query, which would lead you to this.

  3. #3
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    I can't read a thing in that screenshot
    Yes, it's best to copy-and-paste from your IDE rather than posting screenshots. Even if they're big enough to be legible, you can't search them easily.

    Also, you're linking statically with GLEW, so you have to link to the static GLEW library.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    8
    Sorry, I thought the images would be the same size as the files I uploaded.

    Quote Originally Posted by Alfonse Reinheart View Post
    Also, you're linking statically with GLEW, so you have to link to the static GLEW library.
    I am. I'm using the glew32s.lib


    Quote Originally Posted by Agent D View Post
    I can't read a thing in that screenshot, but according your linker errors, you are not inking against GLEW.
    You have to do more than setting up the library path, you also have to tell your IDE/buildsystem to link against
    the GLEW library.
    Which I believe I have done correctly under
    project properties -> configuration settings -> Linker -> input -> additional dependencies
    "glfw3.lib;glew32s.lib;opengl32.lib;%(AdditionalDependencies)"

  5. #5

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    8
    Quote Originally Posted by Alfonse Reinheart View Post
    Are you building for debug or release?
    I am running the project directly out of Visual Studio, so I believe "for debug".



    This was the library created when I downloaded the source, constructed the project with CMake and then built the binary (of glew32s.lib) in Visual Studio

  7. #7
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    Did you build the debug version of the library? I seem to recall that CMake has an annoying habit of not letting you mark your outputs with "D" for debug builds. So you have to rename it yourself, so that you can have separate debug and release builds.

  8. #8
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    8
    I didn't do anything to specify a debug version. You're saying I can do this by renaming the file?

    Will I still need "#define GLEW_STATIC" if I just want to debug? There's a difference between static and debug?


    After going back to CMake, I recall I had an error when trying to build the project.
    So instead, I did download the pre-made binaries and used glew32s.lib under a folder called "release". All of the binaries were under "release".
    Sorry for the inaccuracy

    Code :
    The C compiler identification is MSVC 18.0.30723.0
    The CXX compiler identification is MSVC 18.0.30723.0
    Check for working C compiler using: Visual Studio 12 2013
    Check for working C compiler using: Visual Studio 12 2013 -- works
    Detecting C compiler ABI info
    Detecting C compiler ABI info - done
    Check for working CXX compiler using: Visual Studio 12 2013
    Check for working CXX compiler using: Visual Studio 12 2013 -- works
    Detecting CXX compiler ABI info
    Detecting CXX compiler ABI info - done
    Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
     
    ######################THE ERROR IS HERE######################
    CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPkgConfig.cmake:388 (message):
      pkg-config tool not found
    Call Stack (most recent call first):
      C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPkgConfig.cmake:502 (_pkg_check_modules_internal)
      CMakeLists.txt:26 (pkg_check_modules)
    ########################################################
     
     
    Configuring incomplete, errors occurred!
    See also "C:/_/glew/CMakeFiles/CMakeOutput.log".

    (You may notice that I've reorganized my include and library folders under "C:\_". Even after this I'm still getting the same errors in both CMake and VisualStudio.)



    Got it working. Had to get an x64 glfw thing. (I built an x32 one)
    Figured that one out myself
    Last edited by MissionKMG; 02-07-2015 at 07:57 PM. Reason: SOLVED!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •