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

Static linking does not work #306

Open
burns134 opened this issue Nov 17, 2019 · 1 comment
Open

Static linking does not work #306

burns134 opened this issue Nov 17, 2019 · 1 comment

Comments

@burns134
Copy link

I compiled a static version of glbinding using cmake (libglbinding.a), but when i try to link this into my project I just get many errors like: undefined reference to '__imp__ZN2gl8glEnableENS_6GLenumE'

I'm using CLion and the latest version of CMake.
Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(blobs)

include_directories(include)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_FIND_LIBRARY_SUFFIXES, ".a")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")

find_package(glfw3 REQUIRED)
#find_package(glbinding REQUIRED)
find_package(glm REQUIRED)

add_executable(blobs src/main.cpp src/shader.cpp)
target_link_libraries(blobs glfw3 D:/msys64/mingw64/lib/libglbinding.a glm)

The reason I want to statically link is so that I can create a standalone executable for my project. If instead I use the dynamic linking (glbinding::glbinding), when I run the executable it says it can't find the dll file.
To note, the program does run fine if it isn't statically linked when run in CLion (but cannot be run as a standalone executable).
This is my first time using CMake and CLion so I apologise for not really knowing what to do. Please say if you need any more information. :)

@scheibel
Copy link
Member

scheibel commented Aug 13, 2020

Maybe not as strictly related to your issue, but an issue nonetheless: glbinding, even when build as statically linked library, will link the standard C++ library dynamically.
More related to your issue is the unsuccessful search of the glbinding library. You may need to copy the .dll to your working directory; next to your executable.
We currently advise against using glbinding as statically linked library.
Another issue I see is the direct mentioning of the static library of glbinding. You should use our exported glbinding::glbinding cmake target as it comes with additional headers and compiler definitions.

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

No branches or pull requests

2 participants