Writing an app using buildroot

  • Hello,

    To run programs on the development board, you can use various compilation methods such as WSL, virtual machines, and hosts for cross-compiling. Then, transfer the compiled files to the development board for execution.
  • Yes, but then I can't use the libraries that are already in the buildroot. For example if I want to use curl library I can't because it'll be different on the compile machine. I want to know how to setup the environment so I can use the toolchain link with libraries that I've selected in buildroot
  • When cross-compiling a program, it's crucial to specify the library, header file directories, and library paths. Here's an example:

    Code: Select all

    arm-rockchip830-linux-uclibcgnueabihf-gcc test.c -o test -I/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include -L/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib -lcurl -lcrypto -lssl -lz
    
    1. test.c is the program to be cross-compiled
    2. /home/luckfox-pico is my SDK path
  • Thank you for this . How would you put this in a CMakeLists.txt file. I want to use curl with the RKNN model tutorial
  • I'd also like to have a minimal 'helloWorld.c" example to work from.

    I believe I have all the build tools installed correctly on my Docker image, but when I try to run the above command, I get:

    arm-rockchip830-linux-uclibcgnueabihf-gcc: command not found

    Thanks!
  • torchris4 wrote: 2024-01-29 20:37 I'd also like to have a minimal 'helloWorld.c" example to work from.

    I believe I have all the build tools installed correctly on my Docker image, but when I try to run the above command, I get:

    arm-rockchip830-linux-uclibcgnueabihf-gcc: command not found

    Thanks!
    You need to add the path to your cross-compilation tools to your system's PATH environment variable:
    https://wiki.luckfox.com/Luckfox-Pico/L ... -c-program
    企业微信截图_1706577518430.png
  • Robbal wrote: 2024-01-29 14:55 Thank you for this . How would you put this in a CMakeLists.txt file. I want to use curl with the RKNN model tutorial
    Add the following content to rknpu2/examples/RV1106_RV1103/rknn_yolov5_demo/CMakeLists.txt:

    Code: Select all

    #Set header file search path
    include_directories(/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include)
    
    #Set library file search path
    link_directories(/home/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib)
    
    #Explicitly specify the linked library
    target_link_libraries(rknn_yolov5_demo curl crypto ssl z)
    
  • Thanks! Fixing the PATH up worked! There's a lot of steps to work through! :D
  • Thanks

    I get this error still. How did you guys include the curl. I have added it in my buildroot and can see curl libary in the include directory.

    Code: Select all

    RV1106_RV1103/rknn_yolov5_demo/src/main.cc:32:10: fatal error: curl/curl.h: No such file or directory
     #include <curl/curl.h>
    My Bad.. my path was wrong. I get this now

    Code: Select all

    cannot find -lcurl
    

    Code: Select all

    make_minimum_required(VERSION 3.4.1)
    
    project(rknn_yolov5_demo)
    
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--allow-shlib-undefined")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--allow-shlib-undefined")
    
    # install target and libraries
    set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/rknn_yolov5_demo_${CMAKE_SYSTEM_NAME})
    
    set(CMAKE_SKIP_INSTALL_RPATH FALSE)
    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
    set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
    
    # rknn api
    set(RKNN_API_PATH ${CMAKE_SOURCE_DIR}/../../../runtime/RV1106/${CMAKE_SYSTEM_NAME}/librknn_api)
    set(RKNN_RT_LIB ${RKNN_API_PATH}/armhf/librknnmrt.so)
    
    include_directories(${RKNN_API_PATH}/include)
    include_directories(${CMAKE_SOURCE_DIR}/../../3rdparty)
    
    # rknn_yolov5_demo
    include_directories(${CMAKE_SOURCE_DIR}/include)
    
    add_executable(rknn_yolov5_demo
                src/main.cc
                src/postprocess.cc
    )
    
    #Set header file search path
    include_directories(/home/Projects/luckfox/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include)
    
    #Set library file search path
    link_directories(/home/Projects/luckfox/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/lib)
    
    
    target_link_libraries(rknn_yolov5_demo curl
    ${RKNN_RT_LIB}
    )
    
    # install target and libraries
    set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/rknn_yolov5_demo_${CMAKE_SYSTEM_NAME})
    install(TARGETS rknn_yolov5_demo DESTINATION ./)
    
    
    install(PROGRAMS ${RKNN_RT_LIB} DESTINATION lib)
    install(DIRECTORY model DESTINATION ./)