首页 > 解决方案 > CMAKE Build 使用 arm-none-eabi-gcc 编译器失败...“netinet/in.h:没有这样的文件或目录”和“--检查编译器是否接受 -pthread - no”

问题描述

我正在尝试将Zenoh 协议移植到 RIOT-OS。我使用 RIOT 的本机模拟器让它工作,但未能为 Board 编译代码。

问题出在我使用 CMAKE 构建 git repo 时。当我使用 linux 的 gcc 和 g++ 编译器编译它时,一切正常。

但是,当我使用arm-none-eabi-gcc 编译存储库时,构建失败。repo ZHe给出以下错误“致命错误:netinet/in.h:没有这样的文件或目录”....#include netinet/in.h>

回购Zenoh-C给出以下错误:

-- 正在寻找 pthread_create - 未找到“....”无法找到线程(缺少:Threads_FOUND)

Zenoh-C 回购错误

-- Check for working C compiler: /bin/arm-none-eabi-gcc

-- Check for working C compiler: /bin/arm-none-eabi-gcc -- works

.....
-- Check for working CXX compiler: /bin/arm-none-eabi-g++

-- Check for working CXX compiler: /bin/arm-none-eabi-g++ -- works
...

-- Configuring on/for Generic

-- Looking for pthread.h

-- Looking for pthread.h - found

-- Looking for pthread_create

-- Looking for pthread_create - not found

-- Check if compiler accepts -pthread

-- Check if compiler accepts -pthread - no
...

CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.13/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:70 (find_package)

-- Configuring incomplete, errors occurred!

**//ZHe Repo Error**

/home/brenton/Downloads/zhe-master/example/platform/platform-udp.h:4:10: fatal error: netinet/in.h: No such file or directory
 #include netinet/in.h>

compilation terminated.

标签: cmakearmiotriot-os

解决方案


免责声明:我是 RIOT-OS 的新手。

arm-none-eabi工具链应该针对裸机环境。
这意味着您的目标环境可能没有 pthread 库,也没有与 TCP/IP 相关的头文件。您尝试移植的软件的构建过程可能假设 pthread 库存在并且所需的头文件位于标准(从 Linux 角度)位置。

看来你很幸运 RIOT-OS 有一个 pthread 库,并且在目录中列出了netinet/in.h头文件sys/posix

这可能意味着您需要修改 Zenoh 包的 CMakeLists.txt,以便包含和库目录将指向 RIOT-OS libpthread.a 库和 RIOT-OS posix 包含目录。


推荐阅读