Closed SpartanJ closed 8 years ago
Original comment by Vadim Melnicuk (Bitbucket: vadimmelnicuk, GitHub: vadimmelnicuk).
I have linked opengl32 using find_package(OpenGL REQUIRED) and target_link_libraries(${OPENGL_gl_LIBRARY}) later. I am also including <GL/glew.h> before
Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).
I don't use CMake, but i did a quick test and builded without problems.
I'm pretty sure that your mistake is here:
target_link_libraries(${OPENGL_gl_LIBRARY})
it should be:
target_link_libraries(binaryname ${OPENGL_LIBRARIES})
You can see the CMakeLists file that i created, here: http://pastebin.com/aVvrt6Nx ( if you wan't to use it you'll need to get the FindSDL2.cmake file from here: https://github.com/tcbrindle/sdl2-cmake-scripts ( and place it in the subfolder cmake ). And used mingw to build it ( cmake -G "MinGW Makefiles" CMakeLists.txt ).
Original comment by Vadim Melnicuk (Bitbucket: vadimmelnicuk, GitHub: vadimmelnicuk).
I am trying to link against SOIL2 static library, that is libsoil2.a I have also changed OPENGL_gl_LIBRARY to OPENGL_LIBRARIES, but soil still fails to find a reference to opengl functions.
Original comment by Martín Lucas Golini (Bitbucket: SpartanJ, GitHub: SpartanJ).
If you want to, you can show me the CMakeList.txt that you are using. But since i don't even know more than the basics of CMake and i don't provide support for CMake with the library, i think that it would be more appropriate to ask how to solve your issue in a CMake forum, since it's not a problem with SOIL but with your Makefile generation. Anyways, show me your CMake file at least to see if i can help.
Original comment by Vadim Melnicuk (Bitbucket: vadimmelnicuk, GitHub: vadimmelnicuk).
Hello, Martin. Sorry for the late response. I have included my CMakeLists.txt below: Also, this links well on linux and osx, windows complains about gl references though.
#!c
cmake_minimum_required(VERSION 3.6)
project(Neoconomy)
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(SOURCE_FILES main.cpp HUGE_LIST_OF_FILES)
add_executable (${PROJECT_NAME} ${SOURCE_FILES})
find_package(OpenGL REQUIRED)
find_package(glew REQUIRED)
find_package(glfw3 3.2 REQUIRED)
find_package(soil2 REQUIRED)
if (WIN32)
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES} ${SOIL2_LIBRARIES})
else ()
if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework CoreFoundation" ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES} ${SOIL2_LIBRARIES})
else ()
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} ${GLEW_LIBRARIES} ${SOIL2_LIBRARIES})
endif (APPLE)
endif (WIN32)
include_directories(${CMAKE_SOURCE_DIR}/include) # Header only libraries are found here
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLEW_INCLUDE_DIR}) # GLEW INCLUDE DIR DOI!
include_directories(${GLFW_INCLUDE_DIR}) # GLFW INCLUDE DIR DOI!
include_directories(${SOIL2_INCLUDE_DIR})
Original comment by Rubick (Bitbucket: CuriousRubick, GitHub: CuriousRubick).
I fixed this problem by simply linking SOIL2 before opengl32.lib . If using Codeblocks, go to build options -> linker settings, and move SOIL2 above opengl.
Wasn't an issue in Visual Studio.
Original report by Vadim Melnicuk (Bitbucket: vadimmelnicuk, GitHub: vadimmelnicuk).
I am getting the list of following errors while linking static library on Windows using CMake: