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:
Have you tried to remove the
glbinding
fromtarget_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 alibrary not found
. To verify the content of${GLBINDING_LIBRARIES}
you can print it to cmake output, e.g., viamessage(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