I tried to Link my c++ programm with the Rockey library (Rockey is a company that produces usb hardware keys) but during compilation I get the following error [R4ND_Random]+0x12f): undefined reference to `??3@YAXPEAX@Z’
My CMake file looks like this:
cmake_minimum_required(VERSION 3.22)
project(cppTest)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_CXX_FLAGS "-fpermissive")
file(GLOB HEADERS src/*.h)
file(GLOB SOURCES src/*.cpp)
include_directories(${CMAKE_SOURCE_DIR}/Rockey/include)
link_directories(${CMAKE_SOURCE_DIR}/Rockey/lib)
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})
target_link_libraries(${PROJECT_NAME} Rockey4ND_64.lib Rockey4ND_X64.lib)
target_link_libraries(${PROJECT_NAME} ws2_32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Applications")
and the build output looks like this:
[main] Configuring project: cppTest
[proc] Executing command: C:msys64mingw64bincmake.EXE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:msys64ucrt64bingcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:msys64ucrt64bing++.exe --no-warn-unused-cli -SC:/Users/svob/Desktop/cppTest -Bc:/Users/svob/Desktop/cppTest/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring done (3.3s)
[cmake] -- Generating done (1.2s)
[cmake] -- Build files have been written to: C:/Users/svob/Desktop/cppTest/build
[main] Building folder: c:/Users/svob/Desktop/cppTest/build all
[build] Starting build
[proc] Executing command: chcp
[proc] Executing command: C:msys64mingw64bincmake.EXE --build c:/Users/svob/Desktop/cppTest/build --config Debug --target all -j 6 --
[build] [ 14%] Linking CXX executable bincppTest.exe
[build] Warning: corrupt .drectve at end of def file
[build] Warning: corrupt .drectve at end of def file
[build] Warning: corrupt .drectve at end of def file
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[??_GxMutex@@QEAAPEAXI@Z]+0x26): undefined reference to `??3@YAXPEAX@Z'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_Read_UserID]+0x233): undefined reference to `??3@YAXPEAX@Z'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_Write_UserID]+0x276): undefined reference to `??3@YAXPEAX@Z'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_Random]+0x12f): undefined reference to `??3@YAXPEAX@Z'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_TurnOff]+0x266): undefined reference to `??3@YAXPEAX@Z'
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_SeedCode]+0x16f): more undefined references to `??3@YAXPEAX@Z' follow
[build] C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/svob/Desktop/cppTest/Rockey/lib/Rockey4ND_64.lib(./x64/release/R4ND_API.obj):(.text[R4ND_Find]+0x1a): undefined reference to `__chkstk'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFilescppTest.dirbuild.make:184: bin/cppTest.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFilesMakefile2:82: CMakeFiles/cppTest.dir/all] Error 2
[build] mingw32-make: *** [Makefile:90: all] Error 2
[proc] The command: C:msys64mingw64bincmake.EXE --build c:/Users/svob/Desktop/cppTest/build --config Debug --target all -j 6 -- exited with code: 2
[driver] Build completed: 00:00:05.070
[build] Build finished with exit code 2
can anyone help me the linking works perfectly fine in my other projects but I have no clue why its not working here