简体   繁体   English

CLion、Windows 10 上的 libigl、GLEW、GLFW 和 Eigen。链接器错误

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

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.我正在使用 CLion 构建一个包含四个外部库的项目。 I'm trying to link Eigen, GLEW, GLFW, and libigl.我正在尝试链接 Eigen、GLEW、GLFW 和 libigl。 I'm using the VC++ compiler in VS 2015.我在 VS 2015 中使用 VC++ 编译器。

This is one iteration of my cmake file:这是我的 cmake 文件的一次迭代:

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++.我已经在 VC++ 中将 glew 库(32 位和 64 位)添加到它们各自的文件夹中。 I've also added the glew32.dll files to (64 and 32 bit) to their respective folders in the system folders.我还将 glew32.dll 文件(64 位和 32 位)添加到系统文件夹中各自的文件夹中。 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.如果我定义在我的 Cmake 文件中查找它们的位置,我认为我不需要这样做,但我不完全确定。

This is my folder structure in CLion: CLion folder structure.这是我在CLion 中的文件夹结构CLion folder structure。

Here's what main.cpp contains in case it matters:这是 main.cpp 包含的内容,以防万一:

#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.编辑: Tsyvarev 帮助我解决了明显的错误。 Changed everything to 32-bit too.也将所有内容更改为 32 位。 Down to 47 unresolved externals.多达 47 个未解析的外部对象。 Will update once it's working.运行后会更新。 Current Cmake:当前 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:

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!感谢您的帮助!

Command link_libraries affects only on futher targets, so it should be issued before add_executable call.命令link_libraries仅影响其他目标,因此应add_executable调用之前发出。


Also, link_libraries accepts library files , not a directory with them.此外, link_libraries接受库文件,而不是包含它们的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM