PDA

View Full Version : Linking error blowing my mind.



MissionKMG
02-07-2015, 10:18 AM
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?

1623

1624


I am using Visual Studio 2013. None of my code is underlined red in the editor.

// 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;
}

Agent D
02-07-2015, 10:48 AM
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 (https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts).

Alfonse Reinheart
02-07-2015, 10:50 AM
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.

MissionKMG
02-07-2015, 11:38 AM
Sorry, I thought the images would be the same size as the files I uploaded.


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



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;%(AdditionalDep endencies)"

Alfonse Reinheart
02-07-2015, 11:47 AM
Are you building for debug or release?

MissionKMG
02-07-2015, 11:48 AM
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

Alfonse Reinheart
02-07-2015, 12:25 PM
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.

MissionKMG
02-07-2015, 12:54 PM
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



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 ;)