I am trying to make a project that utilises OpenGL via GLAD and GLFW, however I am stuck at a problem which is every time I try to build and run my application, it fails with
LNK2019: unresolved external symbol gladLoadGLLoader referenced in function "public: __cdecl IrixRenderer::IrixRenderer(void)" (??0IrixRenderer@@QEAA@XZ)
My project is structured like so:
Nexus/
├─ Nexus/
│ ├─ CMakeLists.txt
├─ Irix/
│ ├─ CMakeLists.txt
├─ CMakeLists.txt
The source for the root CMakeLists.txt is
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
project ("Nexus")
# Add include directories.
include_directories ("${CMAKE_SOURCE_DIR}/Dependencies/include")
# Add link directories.
link_directories ("${CMAKE_SOURCE_DIR}/Dependencies/lib")
# Include sub-projects.
add_subdirectory ("Nexus")
add_subdirectory ("Irix")
add_subdirectory ("Solaris")
and the source for the Irix/CMakeLists.txt file is
add_library(Irix STATIC "Irix.cpp" "Irix.h")
# Find the OpenGL package.
find_package(OpenGL REQUIRED)
# Link against GLFW, OpenGL, GLM and freetype.
target_link_libraries(Irix glfw3 ${OPENGL_PACKAGE} freetype)
I have tried switching from target_link_libraries(Irix glfw3 opengl32 freetype)
to the find_package(OpenGL REQUIRED)
and ${OPENGL_PACKAGE}
alternative, however that did not work.
I also tried searching for similar problems, however none of the results were satisfactory, and they did not fix the problem I had.