Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. error : when control gpio on raspberry pi

error : when control gpio on raspberry pi

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
raspberry piwiringpi
1 Posts 1 Posters 297 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Son DongSeong
    wrote on last edited by
    #1

    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/CrossCompileQtForRpi

    When 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/WiringPi

    After 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 pc

    I 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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved