Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linking glbinding with cmake

I'm trying to use glbinding in my own project. I'm using cmake to build everything. The problem is linker cannot find this library. Probably I don't build library thus it cannot be linked, but I don't know how to achive that. I've written linking code according to https://github.com/hpicgs/glbinding#linking-binaries.

Cmake:

set(SOURCE_FILES main.cpp)

add_executable(AKOpenGLEngine ${SOURCE_FILES})

set(CMAKE_PREFIX_PATH ${CMAKE_MODULE_PATH} glbinding )
find_package(glbinding REQUIRED)
include_directories(${GLBINDING_INCLUDES})
target_link_libraries(AKOpenGLEngine glbinding ${GLBINDING_LIBRARIES})

Error:

Linking CXX executable AKOpenGLEngine
ld: library not found for -lglbinding

main.cpp:

#include <glbinding/gl/gl.h>

int main(void) {
    glbinding::Binding::initialize();
    exit(EXIT_SUCCESS);
}

My current project structure:

project structure

like image 966
Adrian Krupa Avatar asked Nov 23 '25 20:11

Adrian Krupa


1 Answers

Have you tried to remove the glbinding from target_link_libraries? ${GLBINDING_LIBRARIES} should be sufficient; it passes <your_specific_file_path_to_glbinding_library> to the linker. With -lglbinding the linker searches for a library within some default directories, your glbinding or build directory not included, thus throwing a library not found. To verify the content of ${GLBINDING_LIBRARIES} you can print it to cmake output, e.g., via message(STATUS ${GLBINDING_LIBRARIES}). However, i also suggest to integrate glbinding as external project as suggested by @janisz.

EDIT: sorry, didn't see the valid, but collapsed answer of @jet47

like image 190
cgcostume Avatar answered Nov 26 '25 12:11

cgcostume