yocto bitbake无法找到包装纸标题(包括_next stind.h没有这样的文件)

发布于 2025-02-07 12:57:51 字数 6651 浏览 2 评论 0 原文

我正在尝试创建一个BitBake食谱,以构建位于本地文件夹中的一些源代码(而不是从远程存储库中获取)。

运行BitBake后,我希望在结果映像中拥有一个可执行文件和共享库。

源代码包括三个CMakelists。

到目前为止,我能够:

  • 运行CMake自行运行以在主机上和目标(即不使用BitBake)上构建源代码
  • ,并通过使用变量OECMAKE_SOURCEPATH正确指向源代码。
  • 使用默认的do_compile()开始运行cmake,

在do_compile()的情况下,构建失败,

In file included from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Inc/typedefs.h:29,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/DOIP/DOIP.h:32,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_MAIN/ISOUDS_Server_Cfg.h:30,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_ClearDiagInfo/ISOUDS_ClearDiagInfo_Cfg.c:25:
| /home/myname/project/nxp_s32/build_s32g274asbc2/tmp/work/aarch64-ms-linux/embitel-uds/1.0.0-r0/recipe-sysroot-native/usr/lib/aarch64-ms-linux/gcc/aarch64-ms-linux/10.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
|     9 | # include_next <stdint.h>
|       |                ^~~~~~~~~~
| compilation terminated.
| make[2]: *** [CMakeFiles/uds-server.dir/build.make:264: CMakeFiles/uds-server.dir/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_ClearDiagInfo/ISOUDS_ClearDiagInfo_Cfg.c.o] Error 1
| In file included from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Inc/typedefs.h:29,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/DOIP/DOIP.h:32,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_MAIN/ISOUDS_Server_Cfg.h:30,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_CntrlDTCSetting/ISOUDS_CntrlDTCSetting.c:13:
| /home/myname/project/nxp_s32/build_s32g274asbc2/tmp/work/aarch64-ms-linux/embitel-uds/1.0.0-r0/recipe-sysroot-native/usr/lib/aarch64-ms-linux/gcc/aarch64-ms-linux/10.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
|     9 | # include_next <stdint.h>
|       |                ^~~~~~~~~~

但确实存在stdint.h。我查看了什么是“ include_next”,它是。我认为GCC正在使用它来修改目标环境的标题,也就是说,这是一个跨补偿器问题。 我认为这将表明CMAKE未正确配置用于交叉兼容,或者在修改后的标头的正确位置中未查看。

I 从未遇到此问题,使用相同的跨编译器为同一目标环境构建其他源代码。我的.bb食谱也使用与其他软件包相同的变量编写。我什至比较了此失败的配方和其他成功的配方的cmakeoutput.log和cmakecache.txt,并看到大多数相关变量设置为具有相同的值。

这使我相信这可能是cmakelists.txt和尚未正确配置此特定源代码的cmake 的问题。

我已经尝试添加 -dcmake_no_system_from_imported = 1 基于此线程。 我还避免了基于这个

但是,我因可能缺少的东西而感到不知所措。

我提到的其他问题: 与yocto reciepe makefile一起引用gcc,无法找到stdint

这是我的cmakelists供参考:

cmake_minimum_required(版本3.13)

project("MyUDS"
    VERSION "1.0.0"
    LANGUAGES C)

include(GNUInstallDirs)

## --- C++ build flags ---
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_C_FLAGS "-MMD -MP -O4 -fcommon")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")

# Set version
set(PROJECT_VERSION_MAJOR 0 CACHE STRING "")
set(PROJECT_VERSION_MINOR 0 CACHE STRING "")
set(PROJECT_VERSION_PATCH 0 CACHE STRING "")
set(PROJECT_VERSION_BUILD 0 CACHE STRING "")

# changes binary and library outputs to ./build/bin and ./build/lib
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

add_library(uds-server SHARED)

set_target_properties(uds-server PROPERTIES
    VERSION ${PROJECT_VERSION}
    SOVERSION ${PROJECT_VERSION_MAJOR})

add_subdirectory(src/3rdparty/udsdoip)

- src/3rdparty/udsdoip中的cmakelists

file(GLOB_RECURSE sched_sources ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Sched/*.c)
add_executable(udsserver ${sched_sources})
target_link_libraries(udsserver uds-server pthread)
target_include_directories(
    udsserver
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Inc
            ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Sched/Inc
            ...
            ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Src/Inc
)

add_subdirectory(UDSSrvonDOIP/DoIPSrvProcess)

install(TARGETS udsserver DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/service/uds_server.sh DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/service/uds_server.service
        DESTINATION /etc/systemd/system
)

- udssrvondoip/doipsrvprocess in src/3rdparty/udsdoip ---------------------------------------------------------------------------------------------------------------------------------------------------------------------

project(lib-uds-server)

# Enable helper debugging messages
target_compile_definitions(
    uds-server PUBLIC DEBUG_SOCKCOMM DOIP_SERVER_PRINT_TCP_RX_PACKET_DATA DOIP_SERVER_PRINT_FOUND_NET_DEVS
)

file(GLOB_RECURSE isouds_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)

target_sources(uds-server PRIVATE ${isouds_sources})

target_include_directories(
    uds-server
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Inc
            ${CMAKE_CURRENT_SOURCE_DIR}/Sched
            ${CMAKE_CURRENT_SOURCE_DIR}/Sched/Inc
            ...
            ${CMAKE_CURRENT_SOURCE_DIR}/Src/ISOUDS/ISOUDSSecurDtaTrans
)

install(TARGETS uds-server
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

I'm trying to create a bitbake recipe to build some source code that resides in a local folder (as opposed to fetching from a remote repo).

After running bitbake, I expect to have an executable file and a shared library in the resulting image.

The source code includes three CMakeLists.

So far, I'm able to:

  • Run cmake by itself to build the source code on my host and on the target (i.e. not using bitbake)
  • Using my .bb file, correctly point to the source code by using the variable OECMAKE_SOURCEPATH.
  • start running cmake using the default do_compile()

The build fails during do_compile() with the error:

In file included from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Inc/typedefs.h:29,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/DOIP/DOIP.h:32,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_MAIN/ISOUDS_Server_Cfg.h:30,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_ClearDiagInfo/ISOUDS_ClearDiagInfo_Cfg.c:25:
| /home/myname/project/nxp_s32/build_s32g274asbc2/tmp/work/aarch64-ms-linux/embitel-uds/1.0.0-r0/recipe-sysroot-native/usr/lib/aarch64-ms-linux/gcc/aarch64-ms-linux/10.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
|     9 | # include_next <stdint.h>
|       |                ^~~~~~~~~~
| compilation terminated.
| make[2]: *** [CMakeFiles/uds-server.dir/build.make:264: CMakeFiles/uds-server.dir/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_ClearDiagInfo/ISOUDS_ClearDiagInfo_Cfg.c.o] Error 1
| In file included from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Inc/typedefs.h:29,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/DOIP/DOIP.h:32,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_MAIN/ISOUDS_Server_Cfg.h:30,
|                  from /home/myname/UDS_Server_Integration/src/3rdparty/udsdoip/UDSSrvonDOIP/DoIPSrvProcess/Src/ISOUDS/ISOUDS_CntrlDTCSetting/ISOUDS_CntrlDTCSetting.c:13:
| /home/myname/project/nxp_s32/build_s32g274asbc2/tmp/work/aarch64-ms-linux/embitel-uds/1.0.0-r0/recipe-sysroot-native/usr/lib/aarch64-ms-linux/gcc/aarch64-ms-linux/10.2.0/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory
|     9 | # include_next <stdint.h>
|       |                ^~~~~~~~~~

However, stdint.h does exist. I looked up what "include_next" is and it's a "wrapper header". I think GCC is using this to modify the headers for the target environment, i.e. this is a cross-compiler issue. I assume this would indicate that cmake is not configured correctly for cross-compilation, or not looking in the correct location for the modified headers.

I have never encountered this problem building other source code for the same target environment using the same cross-compiler. My .bb recipe is also written using the same variables as for other packages. I even compared the CMakeOutput.log and CMakeCache.txt for this failing recipe and other successful recipes and saw that most of the relevant variables were set with the same values.

This led me to believe this could be an issue with the CMakeLists.txt and not having configured cmake correctly for this particular source code.

I have tried adding -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 based on this thread.
I have also avoided directly setting the cross-compiler based on this.

However, I'm at a loss for what I could be missing.

Other issues I've referenced:
Referencing gcc with yocto recipe Makefile, unable to find stdint

Here are my CMakeLists for reference:

cmake_minimum_required(VERSION 3.13)

project("MyUDS"
    VERSION "1.0.0"
    LANGUAGES C)

include(GNUInstallDirs)

## --- C++ build flags ---
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_C_FLAGS "-MMD -MP -O4 -fcommon")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")

# Set version
set(PROJECT_VERSION_MAJOR 0 CACHE STRING "")
set(PROJECT_VERSION_MINOR 0 CACHE STRING "")
set(PROJECT_VERSION_PATCH 0 CACHE STRING "")
set(PROJECT_VERSION_BUILD 0 CACHE STRING "")

# changes binary and library outputs to ./build/bin and ./build/lib
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

add_library(uds-server SHARED)

set_target_properties(uds-server PROPERTIES
    VERSION ${PROJECT_VERSION}
    SOVERSION ${PROJECT_VERSION_MAJOR})

add_subdirectory(src/3rdparty/udsdoip)

----- CMakeLists in src/3rdparty/udsdoip ------

file(GLOB_RECURSE sched_sources ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Sched/*.c)
add_executable(udsserver ${sched_sources})
target_link_libraries(udsserver uds-server pthread)
target_include_directories(
    udsserver
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Inc
            ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Sched/Inc
            ...
            ${CMAKE_CURRENT_SOURCE_DIR}/UDSSrvonDOIP/DoIPSrvProcess/Src/Inc
)

add_subdirectory(UDSSrvonDOIP/DoIPSrvProcess)

install(TARGETS udsserver DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/service/uds_server.sh DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/service/uds_server.service
        DESTINATION /etc/systemd/system
)

----- CMakeLists in UDSSrvonDOIP/DoIPSrvProcess ------

project(lib-uds-server)

# Enable helper debugging messages
target_compile_definitions(
    uds-server PUBLIC DEBUG_SOCKCOMM DOIP_SERVER_PRINT_TCP_RX_PACKET_DATA DOIP_SERVER_PRINT_FOUND_NET_DEVS
)

file(GLOB_RECURSE isouds_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c)

target_sources(uds-server PRIVATE ${isouds_sources})

target_include_directories(
    uds-server
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Inc
            ${CMAKE_CURRENT_SOURCE_DIR}/Sched
            ${CMAKE_CURRENT_SOURCE_DIR}/Sched/Inc
            ...
            ${CMAKE_CURRENT_SOURCE_DIR}/Src/ISOUDS/ISOUDSSecurDtaTrans
)

install(TARGETS uds-server
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅语花开 2025-02-14 12:57:51

找到了这个问题,这是一个愚蠢的错误。

我没有继承Yocto设置的Cmake C标志,而跨编译环境则需要。因此,无论我在.bb食谱文件中添加了哪些标志,它们都会在源代码cmakelists.txt中覆盖。

在这里,我设置了C标志,我没有继承Yocto的标志。

set(CMAKE_C_FLAGS "-MMD -MP -O4 -fcommon")

我应该使用现有的标志,并加入了我的源代码特定的标志:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MP -O4 -fcommon")

这使我的构建工作起作用。

Found the issue, and it's a bit of a dumb mistake.

I was not inheriting the CMake C flags set by Yocto that are needed for the cross-compile environment. So no matter what flags I added in my .bb recipe file, they were being overridden in the source code CMakeLists.txt.

Here, where I was setting the C flags, I was not inheriting Yocto's flags.

set(CMAKE_C_FLAGS "-MMD -MP -O4 -fcommon")

I should have used the existing flags and appended the ones specific to my source code like this:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MP -O4 -fcommon")

This got my build working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文