error : when control gpio on raspberry pi
-
I have a raspberry pi (CM4)
I followed the instructions in the following link to set up on both Raspberry pi and Ubuntu (host pc)
link : https://github.com/MuyePan/CrossCompileQtForRpiWhen I created a program called 'helloworld' for Raspberry Pi on my host PC and ran it, it executed successfully.
I want to control gpios on raspberry pi.
so I downloaded wiringPi library and installed it.
link : https://github.com/WiringPi/WiringPiAfter I installed it,
there is the library file, libwiringPi.so in /usr/lib on raspberry pi and in ~/rpi-sysroot/usr/lib on host pc
and there is the header file, wiringPi.h in /usr/include on raspberry pi and in ~/rpi-sysroot/usr/include on host pcI modified the CMakeLists.txt file in Qt Creator as follows.
------------------------------------------------------------------- cmake_minimum_required(VERSION 3.5) project(TestGpio VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) set(PROJECT_SOURCES main.cpp mainwindow.cpp mainwindow.h mainwindow.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(TestGpio MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: # set_property(TARGET TestGpio APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) add_library(TestGpio SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(TestGpio ${PROJECT_SOURCES} ) endif() endif() find_library(WIRINGPI_LIB NAMES wiringPi PATHS /usr/lib) target_link_libraries(TestGpio PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${WIRINGPI_LIB}) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. if(${QT_VERSION} VERSION_LESS 6.1.0) set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.TestGpio) endif() set_target_properties(TestGpio PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) include(GNUInstallDirs) install(TARGETS TestGpio BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(TestGpio) endif() -------------------------------------------------------------------
I changed find_library and target_link_libraries as described above.
When I ran the program, the following error occured.18:30:56: Running steps for project TestGpio... 18:30:56: Starting: "/home/son/Qt/Tools/CMake/bin/cmake" --build /home/son/Documents/TestGpio/build/RPI-Debug --target all install [0/1 ?/sec] Re-running CMake... -- Configuring done (0.1s) CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: WIRINGPI_LIB linked by target "TestGpio" in directory /home/son/Documents/TestGpio -- Generating done (0.0s) CMake Generate step failed. Build files cannot be regenerated correctly. FAILED: build.ninja /home/son/Qt/Tools/CMake/bin/cmake --regenerate-during-build -S/home/son/Documents/TestGpio -B/home/son/Documents/TestGpio/build/RPI- Debug ninja: error: rebuilding 'build.ninja': subcommand failed 18:30:56: The process "/home/son/Qt/Tools/CMake/bin/cmake" exited with code 1. Error while building/deploying project TestGpio (kit: RPI) When executing step "Build" 18:30:56: Elapsed time: 00:00.
I would appreciate it if you could tell me what the problem is and how I should modify the CMakeLists.txt file.