libigl, GLEW, GLFW, and Eigen on CLion, Windows 10. Linker Errors

1

I'm sure I'm missing something trivial, but I can't put my finger on what.

I'm building a project with four external libraries using CLion. I'm trying to link Eigen, GLEW, GLFW, and libigl. I'm using the VC++ compiler in VS 2015.

This is one iteration of my cmake file:

cmake_minimum_required(VERSION 3.9)
project(Lab1)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_CXX_STANDARD 17)

add_executable(Lab1 main.cpp)

include_directories(external/libigl/include)
include_directories(external/glfw/include/)
include_directories(external/eigen-git-mirror/)

include_directories(external/glew_2_1_0/include)

INCLUDE_DIRECTORIES(external/glew_2_1_0/lib/Release/x64)
link_libraries(external/glew_2_1_0/lib/Release/x64)

I have added the glew libraries (both 32 and 64 bit) to their respective folders in VC++. I've also added the glew32.dll files to (64 and 32 bit) to their respective folders in the system folders. I don't think I need to do this if I define where to look for them in my Cmake file, but I'm not entirely sure.

This is my folder structure in CLion: CLion folder structure.

Here's what main.cpp contains in case it matters:

#include <igl/readOFF.h>
#include <igl/viewer/Viewer.h>

Eigen::MatrixXd V;
Eigen::MatrixXi F;

int main(int argc, char *argv[])
{
    // Load a mesh in OFF format
    igl::readOFF("bunny.off", V, F);

    // Plot the mesh
    igl::viewer::Viewer viewer;
    viewer.data.set_mesh(V, F);
    viewer.launch();
}

These are the linker errors I get.

[100%] Linking CXX executable Lab1.exe
    "D:\Actual Program Files\JetBrains\CLion 2017.3.1\bin\cmake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\Lab1.dir --manifests  -- D:\ACTUAL~1\VISUAL~2\VC\bin\link.exe /nologo @CMakeFiles\Lab1.dir\objects1.rsp @C:\Users\Mohammed\AppData\Local\Temp\nm6742.tmp
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::bind_mesh(void)" (?bind_mesh@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "public: void __thiscall igl::viewer::ViewerCore::clear_framebuffers(void)" (?clear_framebuffers@ViewerCore@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "public: void __thiscall igl::viewer::ViewerCore::clear_framebuffers(void)" (?clear_framebuffers@ViewerCore@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glDeleteTextures@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::free_buffers(void)" (?free_buffers@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glDrawElements@16 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::draw_mesh(bool)" (?draw_mesh@OpenGL_state@viewer@igl@@QAEX_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glGenTextures@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::init_buffers(void)" (?init_buffers@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glGetString@4 referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glLineWidth@4 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glPixelStorei@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::bind_mesh(void)" (?bind_mesh@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glPointSize@4 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glPolygonMode@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::draw_mesh(bool)" (?draw_mesh@OpenGL_state@viewer@igl@@QAEX_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glPolygonOffset@8 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::draw_mesh(bool)" (?draw_mesh@OpenGL_state@viewer@igl@@QAEX_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glTexImage2D@36 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::bind_mesh(void)" (?bind_mesh@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glTexParameteri@12 referenced in function "public: void __thiscall igl::viewer::OpenGL_state::bind_mesh(void)" (?bind_mesh@OpenGL_state@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "public: void __thiscall igl::viewer::ViewerCore::draw(class igl::viewer::ViewerData &,class igl::viewer::OpenGL_state &,bool)" (?draw@ViewerCore@viewer@igl@@QAEXAAVViewerData@23@AAVOpenGL_state@23@_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glewInit@0 referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glewGetErrorString@4 referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glewGetString@4 referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetErrorCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwGetPrimaryMonitor referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwGetVideoMode referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwWindowHint referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwDestroyWindow referenced in function "public: void __thiscall igl::viewer::Viewer::launch_shut(void)" (?launch_shut@Viewer@viewer@igl@@QAEXXZ)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function "public: bool __thiscall igl::viewer::Viewer::launch_rendering(bool)" (?launch_rendering@Viewer@viewer@igl@@QAE_N_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetWindowShouldClose referenced in function "void __cdecl glfw_key_callback(struct GLFWwindow *,int,int,int,int)" (?glfw_key_callback@@YAXPAUGLFWwindow@@HHHH@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwGetWindowSize referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwGetFramebufferSize referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwGetWindowAttrib referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetWindowSizeCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function "public: bool __thiscall igl::viewer::Viewer::launch_rendering(bool)" (?launch_rendering@Viewer@viewer@igl@@QAE_N_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwWaitEvents referenced in function "public: bool __thiscall igl::viewer::Viewer::launch_rendering(bool)" (?launch_rendering@Viewer@viewer@igl@@QAE_N_N@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetInputMode referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetKeyCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetCharModsCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetMouseButtonCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetCursorPosCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetScrollCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSetDropCallback referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwMakeContextCurrent referenced in function "public: int __thiscall igl::viewer::Viewer::launch_init(bool,bool)" (?launch_init@Viewer@viewer@igl@@QAEH_N0@Z)
main.cpp.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function "public: bool __thiscall igl::viewer::Viewer::launch_rendering(bool)" (?launch_rendering@Viewer@viewer@igl@@QAE_N_N@Z)
main.cpp.obj : error LNK2001: unresolved external symbol ___glewActiveTexture
main.cpp.obj : error LNK2001: unresolved external symbol ___glewBindBuffer
main.cpp.obj : error LNK2001: unresolved external symbol ___glewBufferData
main.cpp.obj : error LNK2001: unresolved external symbol ___glewDeleteBuffers
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGenBuffers
main.cpp.obj : error LNK2001: unresolved external symbol ___glewAttachShader
main.cpp.obj : error LNK2001: unresolved external symbol ___glewCompileShader
main.cpp.obj : error LNK2001: unresolved external symbol ___glewCreateProgram
main.cpp.obj : error LNK2001: unresolved external symbol ___glewCreateShader
main.cpp.obj : error LNK2001: unresolved external symbol ___glewDeleteProgram
main.cpp.obj : error LNK2001: unresolved external symbol ___glewDeleteShader
main.cpp.obj : error LNK2001: unresolved external symbol ___glewDisableVertexAttribArray
main.cpp.obj : error LNK2001: unresolved external symbol ___glewEnableVertexAttribArray
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetAttribLocation
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetProgramInfoLog
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetProgramiv
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetShaderInfoLog
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetShaderiv
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGetUniformLocation
main.cpp.obj : error LNK2001: unresolved external symbol ___glewLinkProgram
main.cpp.obj : error LNK2001: unresolved external symbol ___glewShaderSource
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUniform1f
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUniform1i
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUniform3fv
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUniform4f
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUniformMatrix4fv
main.cpp.obj : error LNK2001: unresolved external symbol ___glewUseProgram
main.cpp.obj : error LNK2001: unresolved external symbol ___glewVertexAttribPointer
main.cpp.obj : error LNK2001: unresolved external symbol ___glewBindFragDataLocation
main.cpp.obj : error LNK2001: unresolved external symbol ___glewProgramParameteri
main.cpp.obj : error LNK2001: unresolved external symbol ___glewBindVertexArray
main.cpp.obj : error LNK2001: unresolved external symbol ___glewDeleteVertexArrays
main.cpp.obj : error LNK2001: unresolved external symbol ___glewGenVertexArrays
main.cpp.obj : error LNK2001: unresolved external symbol _glewExperimental
Lab1.exe : fatal error LNK1120: 81 unresolved externals
LINK Pass 1 failed. with 1120
NMAKE : fatal error U1077: '"D:\Actual Program Files\JetBrains\CLion 2017.3.1\bin\cmake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"D:\Actual Program Files\Visual Studio 2015\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Actual Program Files\Visual Studio 2015\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Actual Program Files\Visual Studio 2015\VC\BIN\nmake.exe"' : return code '0x2'
Stop. 

Thanks for the help.


EDIT: Tsyvarev helped me out with the obvious errors. Changed everything to 32-bit too. Down to 47 unresolved externals. Will update once it's working. Current Cmake:

cmake_minimum_required(VERSION 3.9)
project(Lab1)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_CXX_STANDARD 17)

link_libraries(../external/glew_2_1_0/lib/Release/Win32/glew32s)


add_executable(Lab1 main.cpp)


include_directories(external/libigl/include)
include_directories(external/glfw/include/)
include_directories(external/eigen-git-mirror/)

include_directories(external/glew_2_1_0/include)

EDIT: SOLVED It all works! Was missing some libraries. Decided to link them locally. Here's the cmake for the next pour soul that comes across this:

cmake_minimum_required(VERSION 3.9)
project(Lab1)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_CXX_STANDARD 17)

link_libraries(../external/glew_2_1_0/lib/Release/Win32/glew32s)
link_libraries(../external/glfw/lib-vc2015/glfw3)

link_libraries(../external/openGL/OPENGL32)
link_libraries(../external/openGL/glut32)
link_libraries(../external/openGL/glu32)

find_package(OpenGL REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS})
#target_link_libraries(${PROJECTNAME} ${OPENGL_LIBRARIES})




add_executable(Lab1 main.cpp)


include_directories(external/libigl/include)
include_directories(external/glfw/include/)
include_directories(external/eigen-git-mirror/)

include_directories(external/glew_2_1_0/include)

Thanks for the help!

c++
cmake
clion
glew
libigl
asked on Stack Overflow Jan 26, 2018 by Mohamed Sayed • edited Jan 26, 2018 by Mohamed Sayed

1 Answer

1

Command link_libraries affects only on futher targets, so it should be issued before add_executable call.


Also, link_libraries accepts library files, not a directory with them.

answered on Stack Overflow Jan 26, 2018 by Tsyvarev

User contributions licensed under CC BY-SA 3.0