Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker errors building Bullet and ImGui examples #97

Closed
AmeliaMesdag opened this issue Feb 17, 2021 · 5 comments
Closed

Linker errors building Bullet and ImGui examples #97

AmeliaMesdag opened this issue Feb 17, 2021 · 5 comments

Comments

@AmeliaMesdag
Copy link

I'm having issues trying to build some of the magnum-examples using Bullet and ImGui, the project was opened in VS 2019 as a CMake project with vcpkg integration. Here's the build output and I've included my configuration.

>------ Rebuild started: Project: CMakeLists, Configuration: Debug ------
  Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.
  
    Checking Build System
    Building Custom Rule C:/Projects/CPP/magnum-examples/src/imgui/CMakeLists.txt
    ImGuiExample.cpp
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::SetCurrentContext(struct ImGuiContext *)" (__imp_?SetCurrentContext@ImGui@@YAXPEAUImGuiContext@@@Z) referenced in function "private: bool __cdecl Magnum::ImGuiIntegration::Context::handleKeyEvent<class Magnum::Platform::Sdl2Application::KeyEvent>(class Magnum::Platform::Sdl2Application::KeyEvent &,bool)" (??$handleKeyEvent@VKeyEvent@Sdl2Application@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@AEAA_NAEAVKeyEvent@Sdl2Application@Platform@2@_N@Z) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct ImGuiIO & __cdecl ImGui::GetIO(void)" (__imp_?GetIO@ImGui@@YAAEAUImGuiIO@@XZ) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::ShowDemoWindow(bool *)" (__imp_?ShowDemoWindow@ImGui@@YAXPEA_N@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl ImGui::Begin(char const *,bool *,int)" (__imp_?Begin@ImGui@@YA_NPEBDPEA_NH@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::End(void)" (__imp_?End@ImGui@@YAXXZ) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::SetNextWindowPos(struct ImVec2 const &,int,struct ImVec2 const &)" (__imp_?SetNextWindowPos@ImGui@@YAXAEBUImVec2@@H0@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::SetNextWindowSize(struct ImVec2 const &,int)" (__imp_?SetNextWindowSize@ImGui@@YAXAEBUImVec2@@H@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ImGui::Text(char const *,...)" (__imp_?Text@ImGui@@YAXPEBDZZ) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl ImGui::Button(char const *,struct ImVec2 const &)" (__imp_?Button@ImGui@@YA_NPEBDAEBUImVec2@@@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl ImGui::SliderFloat(char const *,float *,float,float,char const *,int)" (__imp_?SliderFloat@ImGui@@YA_NPEBDPEAMMM0H@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl ImGui::ColorEdit3(char const *,float * const,int)" (__imp_?ColorEdit3@ImGui@@YA_NPEBDQEAMH@Z) referenced in function "public: virtual void __cdecl Magnum::Examples::ImGuiExample::drawEvent(void)" (?drawEvent@ImGuiExample@Examples@Magnum@@UEAAXXZ) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ImGui::GetMouseCursor(void)" (__imp_?GetMouseCursor@ImGui@@YAHXZ) referenced in function "public: void __cdecl Magnum::ImGuiIntegration::Context::updateApplicationCursor<class Magnum::Examples::ImGuiExample>(class Magnum::Examples::ImGuiExample &)" (??$updateApplicationCursor@VImGuiExample@Examples@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAAXAEAVImGuiExample@Examples@2@@Z) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\ImGuiExample.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl ImGuiIO::AddInputCharactersUTF8(char const *)" (__imp_?AddInputCharactersUTF8@ImGuiIO@@QEAAXPEBD@Z) referenced in function "public: bool __cdecl Magnum::ImGuiIntegration::Context::handleTextInputEvent<class Magnum::Platform::Sdl2Application::TextInputEvent>(class Magnum::Platform::Sdl2Application::TextInputEvent &)" (??$handleTextInputEvent@VTextInputEvent@Sdl2Application@Platform@Magnum@@@Context@ImGuiIntegration@Magnum@@QEAA_NAEAVTextInputEvent@Sdl2Application@Platform@2@@Z) 
C:\Projects\CPP\magnum-examples\out\build\x64-Debug (default)\Debug\bin\magnum-imgui.exe : fatal error LNK1120: 13 unresolved externals 

Rebuild failed.

CMakeSettings.txt

Visual Studio 2019 Config
vsconfig.txt

vcpkg listing

bullet3:x64-windows                                2.89-1           Bullet Physics is a professional collision detec...
bullet3:x86-windows                                2.89-1           Bullet Physics is a professional collision detec...
corrade:x64-windows                                2020.06          C++11/C++14 multiplatform utility library
corrade:x86-windows                                2020.06          C++11/C++14 multiplatform utility library
corrade[interconnect]:x64-windows                                   Interconnect library
corrade[interconnect]:x86-windows                                   Interconnect library
corrade[pluginmanager]:x64-windows                                  PluginManager library
corrade[pluginmanager]:x86-windows                                  PluginManager library
corrade[testsuite]:x64-windows                                      TestSuite library
corrade[testsuite]:x86-windows                                      TestSuite library
corrade[utility]:x64-windows                                        Utility library
corrade[utility]:x86-windows                                        Utility library
eigen3:x64-windows                                 3.3.9            C++ template library for linear algebra: matrice...
eigen3:x86-windows                                 3.3.9            C++ template library for linear algebra: matrice...
entt:x64-windows                                   3.6.0            Gaming meets modern C++ - a fast and reliable en...
entt:x86-windows                                   3.6.0            Gaming meets modern C++ - a fast and reliable en...
freeglut:x64-windows                               3.2.1-4          Open source implementation of GLUT with source a...
freeglut:x86-windows                               3.2.1-4          Open source implementation of GLUT with source a...
glew:x64-windows                                   2.1.0#10         The OpenGL Extension Wrangler Library (GLEW) is ...
glew:x86-windows                                   2.1.0#10         The OpenGL Extension Wrangler Library (GLEW) is ...
glfw3:x64-windows                                  3.3.2#1          GLFW is a free, Open Source, multi-platform libr...
glfw3:x86-windows                                  3.3.2#1          GLFW is a free, Open Source, multi-platform libr...
glm:x64-windows                                    0.9.9.8          OpenGL Mathematics (GLM)
glm:x86-windows                                    0.9.9.8          OpenGL Mathematics (GLM)
imgui:x64-windows                                  1.81             Bloat-free Immediate Mode Graphical User interfa...
imgui:x86-windows                                  1.81             Bloat-free Immediate Mode Graphical User interfa...
magnum-integration:x64-windows                     2020.06          Integrations for magnum, C++11/C++14 graphics mi...
magnum-integration:x86-windows                     2020.06          Integrations for magnum, C++11/C++14 graphics mi...
magnum-integration[bullet]:x64-windows                              BulletIntegration library
magnum-integration[bullet]:x86-windows                              BulletIntegration library
magnum-integration[eigen]:x64-windows                               EigenIntegration library
magnum-integration[eigen]:x86-windows                               EigenIntegration library
magnum-integration[glm]:x64-windows                                 GlmIntegration library
magnum-integration[glm]:x86-windows                                 GlmIntegration library
magnum-integration[imgui]:x64-windows                               ImGuiIntegration library
magnum-integration[imgui]:x86-windows                               ImGuiIntegration library
magnum:x64-windows                                 2020.06#3        C++11/C++14 graphics middleware for games and da...
magnum:x86-windows                                 2020.06#3        C++11/C++14 graphics middleware for games and da...
magnum[al-info]:x64-windows                                         magnum-al-info utility
magnum[al-info]:x86-windows                                         magnum-al-info utility
magnum[anyaudioimporter]:x64-windows                                AnyAudioImporter plugin
magnum[anyaudioimporter]:x86-windows                                AnyAudioImporter plugin
magnum[anyimageconverter]:x64-windows                               AnyImageConverter plugin
magnum[anyimageconverter]:x86-windows                               AnyImageConverter plugin
magnum[anyimageimporter]:x64-windows                                AnyImageImporter plugin
magnum[anyimageimporter]:x86-windows                                AnyImageImporter plugin
magnum[anysceneconverter]:x64-windows                               AnySceneConverter plugin
magnum[anysceneconverter]:x86-windows                               AnySceneConverter plugin
magnum[anysceneimporter]:x64-windows                                AnySceneImporter plugin
magnum[anysceneimporter]:x86-windows                                AnySceneImporter plugin
magnum[anyshaderconverter]:x64-windows                              AnyShaderConverter plugin
magnum[anyshaderconverter]:x86-windows                              AnyShaderConverter plugin
magnum[audio]:x64-windows                                           Audio library
magnum[audio]:x86-windows                                           Audio library
magnum[cglcontext]:x64-windows                                      CglContext library
magnum[cglcontext]:x86-windows                                      CglContext library
magnum[debugtools]:x64-windows                                      DebugTools library
magnum[debugtools]:x86-windows                                      DebugTools library
magnum[distancefieldconverter]:x64-windows                          magnum-distancefieldconverter utility
magnum[distancefieldconverter]:x86-windows                          magnum-distancefieldconverter utility
magnum[eglcontext]:x64-windows                                      EglContext library
magnum[eglcontext]:x86-windows                                      EglContext library
magnum[fontconverter]:x64-windows                                   magnum-fontconverter utility
magnum[fontconverter]:x86-windows                                   magnum-fontconverter utility
magnum[gl-info]:x64-windows                                         gl-info utility
magnum[gl-info]:x86-windows                                         gl-info utility
magnum[gl]:x64-windows                                              GL library
magnum[gl]:x86-windows                                              GL library
magnum[glfwapplication]:x64-windows                                 GlfwApplication library
magnum[glfwapplication]:x86-windows                                 GlfwApplication library
magnum[glxcontext]:x64-windows                                      GlxContext library
magnum[glxcontext]:x86-windows                                      GlxContext library
magnum[imageconverter]:x64-windows                                  magnum-imageconverter utility
magnum[imageconverter]:x86-windows                                  magnum-imageconverter utility
magnum[magnumfont]:x64-windows                                      MagnumFont plugin
magnum[magnumfont]:x86-windows                                      MagnumFont plugin
magnum[magnumfontconverter]:x64-windows                             MagnumFontConverter plugin
magnum[magnumfontconverter]:x86-windows                             MagnumFontConverter plugin
magnum[meshtools]:x64-windows                                       MeshTools library
magnum[meshtools]:x86-windows                                       MeshTools library
magnum[objimporter]:x64-windows                                     ObjImporter plugin
magnum[objimporter]:x86-windows                                     ObjImporter plugin
magnum[opengltester]:x64-windows                                    OpenGLTester library
magnum[opengltester]:x86-windows                                    OpenGLTester library
magnum[primitives]:x64-windows                                      Primitives library
magnum[primitives]:x86-windows                                      Primitives library
magnum[sceneconverter]:x64-windows                                  magnum-sceneconverter utility
magnum[sceneconverter]:x86-windows                                  magnum-sceneconverter utility
magnum[scenegraph]:x64-windows                                      SceneGraph library
magnum[scenegraph]:x86-windows                                      SceneGraph library
magnum[sdl2application]:x64-windows                                 Sdl2Application library
magnum[sdl2application]:x86-windows                                 Sdl2Application library
magnum[shaderconverter]:x64-windows                                 magnum-shaderconverter utility
magnum[shaderconverter]:x86-windows                                 magnum-shaderconverter utility
magnum[shaders]:x64-windows                                         Shaders library
magnum[shaders]:x86-windows                                         Shaders library
magnum[shadertools]:x64-windows                                     ShaderTools library
magnum[shadertools]:x86-windows                                     ShaderTools library
magnum[text]:x64-windows                                            Text library
magnum[text]:x86-windows                                            Text library
magnum[texturetools]:x64-windows                                    TextureTools library
magnum[texturetools]:x86-windows                                    TextureTools library
magnum[tgaimageconverter]:x64-windows                               TgaImageConverter plugin
magnum[tgaimageconverter]:x86-windows                               TgaImageConverter plugin
magnum[tgaimporter]:x64-windows                                     TgaImporter plugin
magnum[tgaimporter]:x86-windows                                     TgaImporter plugin
magnum[trade]:x64-windows                                           Trade library
magnum[trade]:x86-windows                                           Trade library
magnum[vk-info]:x64-windows                                         vk-info utility
magnum[vk-info]:x86-windows                                         vk-info utility
magnum[vk]:x64-windows                                              Vk library
magnum[vk]:x86-windows                                              Vk library
magnum[wavaudioimporter]:x64-windows                                WavAudioImporter plugin
magnum[wavaudioimporter]:x86-windows                                WavAudioImporter plugin
magnum[wglcontext]:x64-windows                                      WglContext library
magnum[wglcontext]:x86-windows                                      WglContext library
magnum[windowlesscglapplication]:x64-windows                        WindowlessCglApplication library
magnum[windowlesscglapplication]:x86-windows                        WindowlessCglApplication library
magnum[windowlesseglapplication]:x64-windows                        WindowlessEglApplication library
magnum[windowlesseglapplication]:x86-windows                        WindowlessEglApplication library
magnum[windowlessglxapplication]:x64-windows                        WindowlessGlxApplication library
magnum[windowlessglxapplication]:x86-windows                        WindowlessGlxApplication library
magnum[windowlesswglapplication]:x64-windows                        WindowlessWglApplication library
magnum[windowlesswglapplication]:x86-windows                        WindowlessWglApplication library
mimalloc:x64-windows                               1.6.4            Compact general purpose allocator with excellent...
mimalloc:x86-windows                               1.6.4            Compact general purpose allocator with excellent...
openal-soft:x64-windows                            1.21.1           OpenAL Soft is an LGPL-licensed, cross-platform,...
openal-soft:x86-windows                            1.21.1           OpenAL Soft is an LGPL-licensed, cross-platform,...
opengl:x64-windows                                 0.0#8            Open Graphics Library (OpenGL)[3][4][5] is a cro...
opengl:x86-windows                                 0.0#8            Open Graphics Library (OpenGL)[3][4][5] is a cro...
sdl2:x64-windows                                   2.0.14#2         Simple DirectMedia Layer is a cross-platform dev...
sdl2:x86-windows                                   2.0.14#2         Simple DirectMedia Layer is a cross-platform dev...
vulkan:x64-windows                                 1.1.82.1-1       A graphics and compute API that provides high-ef...
vulkan:x86-windows                                 1.1.82.1-1       A graphics and compute API that provides high-ef...
@mosra
Copy link
Owner

mosra commented Feb 17, 2021

Hi,

as far as I'm aware, the dynamic ImGui vcpkg packages are broken as they don't export any symbols ... To work around that, you have these options:

  • either install everything as x86-windows-static, that circumvents the issue as static libs don't need to export anything
  • or build / install / add_subdirectory() magnum-integration manually with a bundled ImGui (that way it ensures the symbols are exported for a dynamic build), it's the second snippet here

Sorry about this, it used to work but we have no control over the other packages in vcpkg, they broke it in one sweeping change (microsoft/vcpkg#5937) and we didn't figure out a solution yet. This issue is also tracked in mosra/magnum-integration#67.

@mosra mosra added this to the 2020.0b milestone Feb 17, 2021
@mosra mosra added this to TODO in Project management via automation Feb 17, 2021
@AmeliaMesdag
Copy link
Author

Understood. I'll remove vcpkg and do subtree builds of everything for now.

@mosra
Copy link
Owner

mosra commented Feb 17, 2021

Vcpkg itself is still useful for the heavier dependencies (although sometimes it's acting up and sometimes just plain cursed) -- one common workflow for users is to have the heavier 3rd party dependencies pulled from vcpkg or other platform-specific package managers and keep just Magnum repos (well, and ImGui) as CMake subprojects.

@AmeliaMesdag
Copy link
Author

Good idea. I settled on using the packaged versions of SDL and OpenAL; and compiling Magnum, Bullet and ImGui. Hopefully vcpkg dynamic libraries get sorted out, they're convenient for testing things out.

@mosra
Copy link
Owner

mosra commented Mar 8, 2021

FYI as of mosra/magnum@62628be (and mosra/magnum#496) it's possible to bundle SDL2 as well (although doing so increases the CMake configure time quite significantly).

I'm closing this in favor of mosra/magnum-integration#67 to have the ImGui/vcpkg issue tracked in a single place, hope that's okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants