I'm trying to compile an application for an embedded linux target board (STM32mp157) and I have a problem when I try to compile and install an application directly into my image.
I use the release Kirkstone of Yocto and I have created a recipe to fetch my source code and my CMakeLists.txt file from a github repository. I use the inherited cmake as it is noted in the yocto documentation (https://docs.yoctoproject.org/dev/dev-manual/new-recipe.html).
CMake: If your source files have a
CMakeLists.txtfile, then your software is built using CMake. If this is the case, you just need to modify the configuration.When you use CMake, your recipe needs to inherit the cmake class and it does not have to contain a do_configure task. You can make some adjustments by setting EXTRA_OECMAKE to pass any needed configure options that are specific to the recipe.
I have installed my yocto SDK on my host PC(Ubuntu 20.04) and I cross-compiled my app using my generated tool-chain. The cross-compiled application runs fine but when I try to compile and install the same source code application directly on my image the application binary differs in size and it creates many runtime errors that end up exiting the application.
File CMakeLists.txt
cmake_minimum_required(VERSION 3.16.3)
project(myapp)
set(Source_Files
"src/main.c"
"src/custom_app.c"
"src/custom_app.h"
)
set(ALL_FILES ${Source_Files})
add_executable(${PROJECT_NAME} ${ALL_FILES})
target_link_libraries(${PROJECT_NAME}
modbus
sqlite3
iothub_client
aziotsharedutil
umqtt
pthread
curl
m
json-c
parson
gpiod
)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
and my recipe .bb
SUMMARY = "Myapp"
DESCRIPTION = "Myapp"
LICENSE = "CLOSED"
DEPENDS = "azure-c-shared-utility azure-iot-sdk-c json-c libmodbus sqlite3 libgpiod parson"
SRC_URI = "\
git://github.com/username/myapprepo.git;branch=main;protocol=ssh \
"
S = "${WORKDIR}/git"
inherit pkgconfig cmake systemd
RDEPENDS:${PN} = "azure-c-shared-utility azure-iot-sdk-c azure-macro-utils-c azure-umqtt-c python3-azure-iot-device"
BBCLASSEXTEND = "native nativesdk"
I tried debugging my application from within my target board, checking the different logs created by my build system's recipe but I still can't get to turn around this problem. Any ideas?