Visitar URL original
Static linking does not work · Issue #306 · cginternals/glbinding · GitHub
Skip to content

Static linking does not work #306

Open

Description

@burns134

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. :)

Activity

  1. scheibel commented on Aug 13, 2020

    @scheibel
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions