I would like to add the Logitech SDK to configure the LEDs on my keyboard.
I'm new to C++ and I've looked at some tutorials but nothing worked. The library I need to add has a . lib extension. With my current configuration, Clion doesn't detect any error and CMake compiles fine. However, when I run main.cpp I get the error:
CMakeFiles\ambiLight.dir/objects.a(main.cpp.obj): In function `main': C:/.../ambiLight/main.cpp:6: undefined reference to `LogiLedInit()'
How can I fix this problem?
Here is my configuration: Tree files:
ambiLight
|
|--- CMakeLists.txt
|--- main.cpp
|--- LogitechLEDLib.h
|--- LogitechLEDLib.lib
|--- LogitechLedEnginesWrapper.dll
CMakeLists.txt:
cmake_minimum_required(VERSION 3.19)
project(ambiLight)
set(CMAKE_CXX_STANDARD 14)
link_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR})
add_executable(ambiLight main.cpp)
target_link_libraries(ambiLight LogitechLEDLib.lib)
main.cpp:
#include <iostream>
#include "LogitechLEDLib.h"
int main() {
std::cout << "Hello, World!" << std::endl;
LogiLedInit();
return 0;
}
CMake output:
C:\...\CLion\ch-0\211.7142.21\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\...\ambiLight
-- Configuring done
-- Generating done
-- Build files have been written to: C:/.../ambiLight/cmake-build-debug
[Finished]
Main.cpp output:
====================[ Build | ambiLight | Debug ]===============================
C:\...\CLion\ch-0\211.7142.21\bin\cmake\win\bin\cmake.exe --build C:\...\ambiLight\cmake-build-debug --target ambiLight -- -j 6
Scanning dependencies of target ambiLight
[ 50%] Building CXX object CMakeFiles/ambiLight.dir/main.cpp.obj
[100%] Linking CXX executable ambiLight.exe
CMakeFiles\ambiLight.dir/objects.a(main.cpp.obj): In function `main':
C:/.../ambiLight/main.cpp:6: undefined reference to `LogiLedInit()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\ambiLight.dir\build.make:105: ambiLight.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:94: CMakeFiles/ambiLight.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:101: CMakeFiles/ambiLight.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:136: ambiLight] Error 2