鱼C论坛

 找回密码
 立即注册
查看: 479|回复: 0

交叉编译C++报错

[复制链接]
发表于 2024-6-22 15:30:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
编译命令:arm-linux-gnueabihf-g++ -std=c++11 -o gpio gpio.cpp -lgpiod -L/usr/local/lib -I/usr/local/include -I/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1 --sysroot=/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf
报错:
:~/code$ arm-linux-gnueabihf-g++ -std=c++11 -o gpio gpio.cpp -lgpiod -L/usr/local/lib -I/usr/local/include -I/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1 --sysroot=/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf
In file included from /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/bits/c++config.h:533:0,
                 from /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/iostream:38,
                 from gpio.cpp:1:
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>


-lgpiod: 指定链接的库,这里是 libgpiod。
-L/usr/local/lib: 指定编译器在链接时查找libgpiod库文件的路径为 /usr/local/lib。
-I/usr/local/include: 指定编译器在编译时查找libgpiod头文件的路径为 /usr/local/include。gpiod.h在这个路径下

-I/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1: 指定编译器在编译时查找 C++ 标准库头文件的路径为 /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1。
--sysroot=/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf: 指定编译器在查找标准系统头文件和库文件时的根路径,即交叉编译环境的根路径。




<features.h>明明是存在这个路径下的子文件夹,下面倒数第三行。

:~/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/parallel$ ls
algobase.h              for_each_selectors.h  partition.h
algo.h                  iterator.h            queue.h
algorithm               list_partition.h      quicksort.h
algorithmfwd.h          losertree.h           random_number.h
balanced_quicksort.h    merge.h               random_shuffle.h
base.h                  multiseq_selection.h  search.h
basic_iterator.h        multiway_merge.h      set_operations.h
checkers.h              multiway_mergesort.h  settings.h
compatibility.h         numeric               sort.h
compiletime_settings.h  numericfwd.h          tags.h
equally_split.h         omp_loop.h            types.h
features.h              omp_loop_static.h     unique_copy.h
find.h                  parallel.h            workstealing.h
find_selectors.h        par_loop.h




详细的错误输出:

Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/7.4.1/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.4-2019.02/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --with-float=hard --with-fpu=vfpv3-d16 --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/sysroots/arm-linux-gnueabihf --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu
Thread model: posix
gcc version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (Linaro GCC 7.4-2019.02)
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-o' 'gpio' '-L/usr/local/lib' '-I' '/usr/local/include' '-I' '/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1' '-shared-libgcc' '-march=armv7-a' '-mtune=cortex-a9' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/7.4.1/cc1plus -quiet -v -I /usr/local/include -I /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1 -imultilib . -imultiarch arm-linux-gnueabihf -iprefix /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/ -isysroot /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf -D_GNU_SOURCE gpio.cpp -quiet -dumpbase gpio.cpp -march=armv7-a -mtune=cortex-a9 -mfloat-abi=hard -mfpu=vfpv3-d16 -mthumb -mtls-dialect=gnu -auxbase gpio -std=c++11 -version -o /tmp/cc9B2mTH.s
GNU C++11 (Linaro GCC 7.4-2019.02) version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (arm-linux-gnueabihf)
        compiled by GNU C version 4.8.4, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1"
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/."
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1/backward"
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/include"
ignoring nonexistent directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/usr/local/include"
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/include-fixed"
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include"
ignoring nonexistent directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/usr/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/usr/include"
ignoring duplicate directory "/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/.
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include/c++/7.4.1/backward
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/include
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/include-fixed
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.4.1/../../../../arm-linux-gnueabihf/include
End of search list.
GNU C++11 (Linaro GCC 7.4-2019.02) version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (arm-linux-gnueabihf)
        compiled by GNU C version 4.8.4, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 92bf6b5e79f37491ed145911db6703d5
In file included from /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/bits/c++config.h:533:0,
                 from /home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/iostream:38,
                 from gpio.cpp:1:
/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/arm-linux-gnueabihf/bits/os_defines.h:39:10: fatal error: features.h: No such file or directory
#include <features.h>
          ^~~~~~~~~~~~





如果在加多一行-I/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1/parallel去指向<features.h>的路径,交叉编译器就找不到上一级路径/home/eke/linux/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/7.4.1下的头文件。
求助大佬们,谢谢!

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-4 16:28

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表