首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >g++找不到交叉编译的boost头

g++找不到交叉编译的boost头
EN

Stack Overflow用户
提问于 2020-11-09 10:23:02
回答 2查看 423关注 0票数 0

编辑

添加了更多信息来重现错误。

我想交叉编译覆盆子Pi 3B+ (armv7l)与GCC 8.3的PCL。为此,我需要boost 1.67,因为这是Pi中的当前库。我就是这样做的:

代码语言:javascript
复制
sudo debootstrap stretch crossdev_folder
sudo chroot crossdev_folder
apt install -y unzip cmake cmake-curses-gui xz-utils
cd /root/

然后,我从这里下载带有硬浮点数(Arm Gnueabihf) GCC 8.3的这里目标并将其内容复制到/usr/

代码语言:javascript
复制
tar -xvf gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz
cd gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/
rm *.txt && cp -r ./* /usr/ && cd /root/
rm -r gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/

然后我交叉编译libboost 1.6.7

代码语言:javascript
复制
wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.zip
unzip boost_1_67_0.zip && rm boost_1_67_0.zip && cd boost_1_67_0/
./bootstrap.sh
sed -i 's/using gcc ;/using gcc : arm : arm-linux-gnueabihf-g++ ;/' project-config.jam
./bjam install toolset=gcc-arm --prefix=/usr -sNO_ZLIB=1 -sNO_BZIP2=1

为了确保我已经安装了它们,我转到/usr/include/,boost/文件夹中有所有的标头。(例如boost/mpl/assert.hpp)

代码语言:javascript
复制
root@felipe:/root# cd /usr/include/
root@felipe:/usr/include# ls boost/mpl/assert.hpp 
boost/mpl/assert.hpp

然后我交叉编译并安装OpenCV-3.4.9 (因为我也需要它),最后我尝试像这样交叉编译PCL

代码语言:javascript
复制
# First install some dependencies
apt-get install -y libflann-dev:armhf libeigen3-dev:armhf libglu1-mesa-dev:armhf freeglut3-dev:armhf mesa-common-dev:armhf

# Download PCL
cd /root/
wget https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.11.1/source.zip
unzip source.zip && rm source.zip && cd pcl/

# Do CMake
mkdir build && cd build
cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DWITH_VTK=OFF ..

在这里,我发现了第一个问题,因为CMake找不到FLANN -它已经安装了apt,我可以在

代码语言:javascript
复制
root@felipe:/root/pcl/build# ls /usr/lib/arm-linux-gnueabihf/pkgconfig/
dri.pc               libdrm_nouveau.pc    xau.pc               xcb-xfixes.pc
flann.pc             libdrm_omap.pc       xcb-dri2.pc          xcb.pc
gl.pc                libdrm_radeon.pc     xcb-dri3.pc          xdamage.pc
glu.pc               libdrm_tegra.pc      xcb-glx.pc           xdmcp.pc
ice.pc               libdrm_vc4.pc        xcb-present.pc       xext.pc
libdrm.pc            pthread-stubs.pc     xcb-randr.pc         xfixes.pc
libdrm_amdgpu.pc     sm.pc                xcb-render.pc        xshmfence.pc
libdrm_exynos.pc     x11-xcb.pc           xcb-shape.pc         xt.pc
libdrm_freedreno.pc  x11.pc               xcb-sync.pc          xxf86vm.pc

因此,我必须对-DCMAKE_PREFIX_PATH=/usr/lib/arm-linux-gnueabihf进行cmake,以指定以前安装的所有:armhf库的安装前缀。由于cmake版本,我收到了一些Boost警告,但是fn似乎正确地找到了boost库。

代码语言:javascript
复制
CMake Warning at /usr/share/cmake-3.7/Modules/FindBoost.cmake:761 (message):
  Imported targets not available for Boost version 106700
Call Stack (most recent call first):
  /usr/share/cmake-3.7/Modules/FindBoost.cmake:865 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.7/Modules/FindBoost.cmake:1470 (_Boost_MISSING_DEPENDENCIES)
  cmake/pcl_find_boost.cmake:33 (find_package)
  CMakeLists.txt:462 (include)


-- Boost version: 1.67.0
-- Found the following Boost libraries:
--   filesystem
--   date_time
--   iostreams
--   system

对交叉汇编的一些修改:

代码语言:javascript
复制
# remove some lines from CMake files
sed -i '11,16d' ../cmake/pcl_find_sse.cmake && sed -i '10 a \ \ \ \  list(APPEND SSE_FLAGS "-marm")' ../cmake/pcl_find_sse.cmake

在这里,当我试图编译时,它会失败,因为它找不到boost headers 编辑:add VERBOSE=1 to make

代码语言:javascript
复制
    root@felipe:/root/pcl/build# make VERBOSE=1
/usr/local/bin/cmake -S/root/pcl -B/root/pcl/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /root/pcl/build/CMakeFiles /root/pcl/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/root/pcl/build'
make -f common/CMakeFiles/pcl_common.dir/build.make common/CMakeFiles/pcl_common.dir/depend
make[2]: Entering directory '/root/pcl/build'
cd /root/pcl/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /root/pcl /root/pcl/common /root/pcl/build /root/pcl/build/common /root/pcl/build/common/CMakeFiles/pcl_common.dir/DependInfo.cmake --color=
Dependee "/root/pcl/build/common/CMakeFiles/pcl_common.dir/DependInfo.cmake" is newer than depender "/root/pcl/build/common/CMakeFiles/pcl_common.dir/depend.internal".
Dependee "/root/pcl/build/common/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/root/pcl/build/common/CMakeFiles/pcl_common.dir/depend.internal".
Scanning dependencies of target pcl_common
make[2]: Leaving directory '/root/pcl/build'
make -f common/CMakeFiles/pcl_common.dir/build.make common/CMakeFiles/pcl_common.dir/build
make[2]: Entering directory '/root/pcl/build'
[  0%] Building CXX object common/CMakeFiles/pcl_common.dir/src/point_types.cpp.o
cd /root/pcl/build/common && /usr/bin/arm-linux-gnueabihf-g++  -DPCLAPI_EXPORTS -I/root/pcl/build/include -I/root/pcl/common/include -isystem /usr/include/eigen3 -isystem /root/pcl/recognition/include/pcl/recognition/3rdparty  -Wabi=11 -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion -marm -ffloat-store -fopenmp -O2 -g -DNDEBUG -fPIC   -fopenmp -std=c++14 -o CMakeFiles/pcl_common.dir/src/point_types.cpp.o -c /root/pcl/common/src/point_types.cpp
In file included from /root/pcl/common/include/pcl/type_traits.h:40,
                 from /root/pcl/common/include/pcl/memory.h:46,
                 from /root/pcl/common/include/pcl/impl/point_types.hpp:41,
                 from /root/pcl/common/include/pcl/point_types.h:349,
                 from /root/pcl/common/src/point_types.cpp:37:
/root/pcl/common/include/pcl/point_struct_traits.h:42:10: fatal error: boost/mpl/assert.hpp: No such file or directory
 #include <boost/mpl/assert.hpp>  // for BOOST_MPL_ASSERT_MSG
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
common/CMakeFiles/pcl_common.dir/build.make:62: recipe for target 'common/CMakeFiles/pcl_common.dir/src/point_types.cpp.o' failed
make[2]: *** [common/CMakeFiles/pcl_common.dir/src/point_types.cpp.o] Error 1
make[2]: Leaving directory '/root/pcl/build'
CMakeFiles/Makefile2:122: recipe for target 'common/CMakeFiles/pcl_common.dir/all' failed
make[1]: *** [common/CMakeFiles/pcl_common.dir/all] Error 2
make[1]: Leaving directory '/root/pcl/build'
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

知道我错过了什么吗?谢谢!

更新

当我用--前缀= /usr/local在/usr/local中安装boost时,编译器实际上可以找到标头(我还必须移动flann头)。我终于得到了另一个错误,但这主要与有关。

EN

回答 2

Stack Overflow用户

发布于 2020-11-10 11:46:47

如果cmake无法自动添加路径。用途:link_directoriesinclude_directories

还可以在运行cmake命令之前导出CXXFLAGS。来自初始化

CMake可以根据环境和目标平台为值添加或附加内容--例如,xxxFLAGS环境变量的内容将被添加,其中xxx将是特定于语言的,但不一定与(例如,CXXFLAGS用于CXX,FFLAGS用于Fortran,等等)相同。

另一种解决方案(不是最好的解决方案),因为您已经在修改一些文件,就是直接修改flags.make以添加包含路径,并通过link.txt添加带有-L选项的路径。

票数 0
EN

Stack Overflow用户

发布于 2020-11-15 18:28:05

我不知道这是否是正确的原因,但显然编译器有一些默认目录,可以在其中查找标头和库[链接]。所以我做了

代码语言:javascript
复制
arm-linux-gnueabihf-gcc -v -x c -E -

我得到了

代码语言:javascript
复制
#include <...> search starts here:
 /usr/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/include
 /usr/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/include-fixed
 /usr/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/include
 /usr/bin/../arm-linux-gnueabihf/libc/usr/include

然后,我在/usr/arm-linux-gnueabihf中交叉编译并安装了boost、flann和Eigen,并在pcl/build文件夹中交叉安装了cmake,如

代码语言:javascript
复制
cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DWITH_VTK=OFF \
-DWITH_OPENGL=OFF \
-DCMAKE_PREFIX_PATH=/usr/arm-linux-gnueabihf \
-DCMAKE_INSTALL_PREFIX=/usr/arm-linux-gnueabihf ..

并且它编译了

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64749778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档