c - 为 ARM 交叉编译时 header 子目录错误

标签 c linux gcc arm cross-compiling

我正在尝试使用 x64 机器和 this 为 ARM(树莓派 2)交叉编译一个应用程序(tvheadend)工具链。

我正在使用以下命令行来配置编译: ./configure --arch=arm-linux-gnueabihf --cc=arm-linux-gnueabihf-gcc --disable-avahi --release --cflags=-DOPENSSL_USE_DEPRECATED 然后我只是制作

问题发生在源文件src/utils.c的编译过程中:该文件包含string.h,它是从工具链包含目录中正确选择的(让我们说 ARMTOOLCHAIN/usr/include),然后是 string2.h,它位于 ARMTOOLCHAIN/usr/include/arm-linux-gnueabihf/bits,是从系统目录中选择的,而不是 ARMTOOLCHAIN/usr/include/arm-linux-gnueabihf/bits

In file included from /usr/include/x86_64-linux-gnu/bits/byteswap.h:35:0,
                 from ARMTOOLCHAIN/usr/include/endian.h:61,
                 from /usr/include/x86_64-linux-gnu/bits/string2.h:51,
                 from ARMTOOLCHAIN/usr/include/string.h:637,
                 from src/utils.c:21:
src/utils.c: In function ‘sbuf_put_be16’:
src/utils.c:397:9: error: invalid 'asm': invalid operand for code 'w'
   u16 = htons(u16);
         ^

问题是编译器不会在 ARMTOOLCHAIN/usr/include/arm-linux-gnueabihf 中搜索 bits 子目录。我尝试将 -IARMTOOLCHAIN/usr/include/arm-linux-gnueabihf 指定为选项,并在 ARMTOOLCHAIN/usr/include 中创建指向 bits 的符号链接(symbolic link)(避免 arm-linux-gnueabihf),但这些都不起作用。

最佳答案

尝试在您的configure 调用中修改cflags:

--cflags="-DOPENSSL_USE_DEPRECATED -nostdinc -nostdinc++"

关于c - 为 ARM 交叉编译时 header 子目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34532481/

相关文章:

c - 使用 C 语言编程,使用 pow 函数

php - 如何在 Linux 上用 PHP 发送 HTML 邮件

c++ - 在跨平台代码中处理 stdafx.h

c - glob.h 中的 ^ 是什么意思?

c++ - 有人遇到过在 Ubuntu 上找不到 unistd.h 的情况吗?

c - 一个变量中的 32 位十六进制

c - 管道传输时程序输出发生变化

c - 在 4x4 的字符板上搜索字典中的单词

我可以在多线程(pthreads)应用程序中捕获 SIGSEGV 和其他信号并打印导致它的线程或所有线程的回溯吗?

php - Yii2 控制台命令在 linux 上不起作用(基本应用程序)