So I'm making a project where I need a library called dpp. Here is the library structure:
Here is my CMakeLists.txt file:
# Setup vcpkg.
if(NOT DEFINED ENV{VCPKG_ROOT})
set(ENV{VCPKG_ROOT} cmake/vcpkg)
endif()
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
project(app)
# Project settings.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Link dpp library.
set(dpp_DIR "${CMAKE_SOURCE_DIR}/libs/dpp")
# Link libraries.
include_directories("${dpp_DIR}/include/dpp-9.0")
link_directories("${dpp_DIR}/lib/dpp-9.0")
# Assign the include directories.
include_directories("${CMAKE_SOURCE_DIR}/include")
# Gather the header and source files.
file(GLOB_RECURSE INC_FILES "${CMAKE_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE SRC_FILES "${CMAKE_SOURCE_DIR}/src/*.cpp")
# Build.
add_executable(app ${INC_FILES} ${SRC_FILES})
set_target_properties(app PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Link libraries.
target_link_libraries(app dpp)
# Unit tests.
enable_testing()
add_subdirectory(tests)
Now when I build my project I get undefined reference errors
[ 20%] Linking CXX executable bin\app.exe
c:/progra~1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\app.dir/objects.a(hooks.cpp.obj):hooks.cpp:(.text+0x177): undefined reference to `__imp__ZN3dpp5embedC1Ev'
c:/progra~1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\app.dir/objects.a(hooks.cpp.obj):hooks.cpp:(.text+0x1fb): undefined reference to `__imp__ZN3dpp5embedD1Ev'
c:/progra~1/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\app.dir/objects.a(hooks.cpp.obj):hooks.cpp:(.text.unlikely+0x5): undefined reference to `__imp__ZN3dpp5embedD1Ev'
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [CMakeFiles\app.dir\build.make:143: bin/app.exe] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:99: CMakeFiles/app.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:106: CMakeFiles/app.dir/rule] Error 2
mingw32-make: *** [Makefile:133: app] Error 2
I've been stuck in this for hours, I would appreciate any help thanks!