Skip to content

Static linking does not work #306

Open
@burns134

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

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