Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarch64平台安装pcl失败 #2453

Closed
xiaomi2077 opened this issue Jun 13, 2022 · 27 comments
Closed

aarch64平台安装pcl失败 #2453

xiaomi2077 opened this issue Jun 13, 2022 · 27 comments
Labels

Comments

@xiaomi2077
Copy link

Xmake 版本

2.6.7

操作系统版本和架构

Linux nx-desktop 4.9.140-tegra #1 SMP PREEMPT Fri Apr 16 01:50:20 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux

描述问题

安装pcl库时,有如下报错:

note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> boost 1.78.0 [serialization:y, date_time:y, iostreams:y, filesystem:y, system:y, from pcl)
  -> pcl 1.12.1 [shared:y]
please input: y (y/n/m)
y
  => install boost 1.78.0 .. ok
  => install pcl 1.12.1 .. failed

CMake Error at /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/Boost-1.78.0/BoostConfig.cmake:141 (find_package):
  Found package configuration file:
    /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/boost_filesystem-1.78.0/boost_filesystem-config.cmake
  but it set boost_filesystem_FOUND to FALSE so package "boost_filesystem" is
  considered to be NOT FOUND.  Reason given by package:
  No suitable build variant has been found.
  The following variants have been tried and rejected:
  * libboost_filesystem-mt.a (32 bit, need 64)
Call Stack (most recent call first):
  /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/Boost-1.78.0/BoostConfig.cmake:262 (boost_find_component)
  /home/ubuntu/czs/softwares/cmake-3.21.5-linux-aarch64/share/cmake-3.21/Modules/FindBoost.cmake:594 (find_package)
  cmake/pcl_find_boost.cmake:29 (find_package)
  CMakeLists.txt:400 (include)
Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Checking for module 'eigen3'
--   Found eigen3, version 3.4.0
if you want to get more verbose errors, please see:
  -> /home/ubuntu/.xmake/cache/packages/2206/p/pcl/1.12.1/installdir.failed/logs/install.txt
error: install failed!

完整日志文件:
install.txt

此错误应该是libboost_filesystem-mt.a被编译成了32位

期待的结果

期望libboost_filessytem-mt.a编译成64位,并正确安装pcl库

工程配置

set_languages('cxx17')
add_includedirs('include') --添加本项目头文件搜索目录
add_includedirs('/usr/local/cuda/include') -- 否则会找到不到driver_types.h

add_requires("opencv","yaml-cpp",'fmt',"cxxopts","eigen",{system=false}) -- 不使用系统包

add_requires('pcl',{system=false,config={shared=true}}) -- pcl的包会添加boost部分模块的依赖


target('oilfield_common')
    set_kind('shared')
    add_files('common/*.cpp')
    add_packages("opencv",'yaml-cpp','cxxopts','boost')

附加信息和错误日志

执行xmake -vD
输出太长了,保存到下面的文件里了
aa.txt

@xiaomi2077 xiaomi2077 added the bug label Jun 13, 2022
@xiaomi2077
Copy link
Author

图片
上图第一个是我通过xmake require --extra="{config={shared=true},system=false}" boost安装的boost是动态库,且是64位。如下图
图片

第二个是安装pcl时,xmake它自己又安装一次boost,编译出来的库是静态库。使用objdump -a libboost_filesystem-mt.a的输出
图片

@xiaomi2077
Copy link
Author

很奇怪啊,我把124文件夹里的静态库复制到5bc文件夹下,并将5bc目录名改为124。改名后的124(原5bc目录)如下图:
图片
然后执行xmake编译项目,输出如下:

note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> pcl 1.12.1 [shared:y]
please input: y (y/n/m)
y
  => install pcl 1.12.1 .. failed

CMake Error at /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/Boost-1.78.0/BoostConfig.cmake:141 (find_package):
  Found package configuration file:
    /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/boost_filesystem-1.78.0/boost_filesystem-config.cmake
  but it set boost_filesystem_FOUND to FALSE so package "boost_filesystem" is
  considered to be NOT FOUND.  Reason given by package:
  No suitable build variant has been found.
  The following variants have been tried and rejected:
  * libboost_filesystem-mt.so.1.78.0 (32 bit, need 64)
Call Stack (most recent call first):
  /home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2/lib/cmake/Boost-1.78.0/BoostConfig.cmake:262 (boost_find_component)
  /home/ubuntu/czs/softwares/cmake-3.21.5-linux-aarch64/share/cmake-3.21/Modules/FindBoost.cmake:594 (find_package)
  cmake/pcl_find_boost.cmake:29 (find_package)
  CMakeLists.txt:400 (include)
ng Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Checking for module 'eigen3'
--   Found eigen3, version 3.4.0
if you want to get more verbose errors, please see:
  -> /home/ubuntu/.xmake/cache/packages/2206/p/pcl/1.12.1/installdir.failed/logs/install.txt
error: install failed!

这次找到了libboost_filesystem-mt.so.1.78.0动态库,但仍报错The following variants have been tried and rejected: *libboost_filesystem-mt.so.1.78.0 (32 bit, need 64)
这是把这个库识别成了32位,可是libboost_filesystem-mt.so.1.78.0通过file命令查看是64位啊:)

@waruqi
Copy link
Member

waruqi commented Jun 13, 2022

那说明安装的库没问题咯,就是 64 的,是 cmake find 时候,内部调用了啥检测,检测成了 32bit? 那应该是 cmake 的问题吧。。要不你看下 cmake 相关 find package 怎么找的它

默认编译安装 boost ,一般肯定是 64 的。。如果你 host 是 64 的话,就是调用 gcc 默认编译,不会去额外设置修改 arch 的

@xiaomi2077
Copy link
Author

@waruqi 找了一个小时。。。,大佬能再提示提示吗?我对cmake不太熟悉。

@waruqi
Copy link
Member

waruqi commented Jun 13, 2022

可以 google 下相关错误,应该有不少类似的参考:

https://stackoverflow.com/questions/61145830/cmake-error-while-using-find-packageboost-in-cmakelists-txt-no-suitable

@xiaomi2077
Copy link
Author

不知道为什么boost默认编译成32位的库了,解决方法是手动编译下在的boost源码,并安装。--address-model=64指定编译成64位。命令如下:
./bootstrap.sh
./b2 install --prefix=/home/ubuntu/.xmake/packages/b/boost/1.78.0/124a5e8540714d31b251349b7d7f3fd2 --with-filesystem --with-date_time --with-iostreams --with-system --address-model=64 --link=static
然后再使用xmake安装pcl就可以了。
但是安装的pcl不全,少了好多库,如下图,左边是xmake安装的,右边是自己安装的
图片

我看仓库里好像只能安装vtk和cuda,不知道在哪里设置才能安装pcl的全部模块。。。

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

包里有配置 --address-model=64 的,

https://github.com/xmake-io/xmake-repo/blob/a140c62bb87ff301f919b5dcc94f9f6a5c4455d1/packages/b/boost/xmake.lua#L147

而且我看你最早d的截图,里面编译出来也是 64 的。没啥问题
image

@xiaomi2077
Copy link
Author

但是它报错是 libboost_filesystem-mt.a (32 bit, need 64),意思是这个静态库是32位,需要64位的库。而且我也没改pcl和boost的cmake
我这个是aarch64平台,符合 if package:is_arch("x64", "x86_64") then的判断吗?(我不太懂这些架构归类关系

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

@xq114
Copy link
Contributor

xq114 commented Jun 14, 2022

改成package:is_arch(".+64")这样更好吧?目前xmake支持的arch里面64位的都是以64结尾的

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

改成package:is_arch(".+64")这样更好吧?目前xmake支持的arch里面64位的都是以64结尾的

也可以

@xq114
Copy link
Contributor

xq114 commented Jun 14, 2022

我看仓库里好像只能安装vtk和cuda,不知道在哪里设置才能安装pcl的全部模块。。。

可以xmake -vD > log.txt看看cmake log,里面应该有为什么这些组件没有被编译

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

boost 包里面,我加上 arm64 了,更新下仓库再试下,xrepo update-repo

@xiaomi2077
Copy link
Author

@waruqi 不行,似乎.+64没有匹配到我的平台。还是报了不是64位的错误。我把boost包的xmake.lua的else分支从address-model=32修改为address-model=64就可以了
图片

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

你执行 xmake l os.arch 给我看下

@xiaomi2077
Copy link
Author

图片

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

在更新下试试

@xiaomi2077
Copy link
Author

好了,谢谢。但是为什么只生成这些库?不能全部的模块都生成吗?
图片

@waruqi
Copy link
Member

waruqi commented Jun 14, 2022

如果它还可以生成其他库,可以自己提 pr 改进下这个包。。https://github.com/xmake-io/xmake-repo/blob/master/packages/p/pcl/xmake.lua

目前 xmake-repo 仓库的包,都是用户根据自己需求,自己维护的。

@xiaomi2077
Copy link
Author

好的,再次感谢

@xiaomi2077
Copy link
Author

xiaomi2077 commented Jul 27, 2022

好了,谢谢。但是为什么只生成这些库?不能全部的模块都生成吗? 图片

我知道为什么只生成这几个库了。
原因:pcl好多库都直接或间接依赖于flann。
https://github.com/xmake-io/xmake-repo/blob/6d323eab58f59d2c1142c1bd8bc20b7f9888a39f/packages/p/pcl/xmake.lua#L31 仓库里这一行把原来cmake的find_package(FLANN 1.9.1 REQUIRED)改为了find_package(flann CONFIG REQUIRED)。可能是CONFIG里没有配置好,不太懂cmake。
解决办法:把仓库里替换FLANN的哪一行注释掉就好了。不过要用xmake提前安装好flann1.9.1

@waruqi
Copy link
Member

waruqi commented Jul 27, 2022

@xq114 这个帮忙看下?

@xq114
Copy link
Contributor

xq114 commented Jul 27, 2022

不过要用xmake提前安装好flann1.9.1

你确定是用xmake安装的flann吗?xmake安装的flann pcl应该找不到才对,这里有cmake的详细log吗

@xiaomi2077
Copy link
Author

不清楚了。我查了一下,xmake装了flann1.9.1,系统库里也找到了libflann 1.9.1。

这里有cmake的详细log吗

cmake日志在哪找?.xmake/cache 和.xmake/packages里都没有

@xq114
Copy link
Contributor

xq114 commented Jul 27, 2022

那应该是用的系统库的flann。可以提供一下.xmake/packages/f/flann/.../1.9.1/cmake/flannConfig.cmake和.xmake/packages/f/flann/.../1.9.1/cmake/flannTargets-release.cmake的内容吗

@xiaomi2077
Copy link
Author

flannConfig.cmake

####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was Config.cmake.in                            ########

get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

macro(set_and_check _var _file)
  set(${_var} "${_file}")
  if(NOT EXISTS "${_file}")
    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
  endif()
endmacro()

macro(check_required_components _NAME)
  foreach(comp ${${_NAME}_FIND_COMPONENTS})
    if(NOT ${_NAME}_${comp}_FOUND)
      if(${_NAME}_FIND_REQUIRED_${comp})
        set(${_NAME}_FOUND FALSE)
      endif()
    endif()
  endforeach()
endmacro()

include("${CMAKE_CURRENT_LIST_DIR}/flannTargets.cmake")
check_required_components("flann")

flannTargets-release.cmake

#----------------------------------------------------------------
# Generated CMake target import file for configuration "Release".
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Import target "flann::flann" for configuration "Release"
set_property(TARGET flann::flann APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(flann::flann PROPERTIES
  IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "ASM_NASM;C"
  IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libflann_s.a"
  )

list(APPEND _IMPORT_CHECK_TARGETS flann::flann )
list(APPEND _IMPORT_CHECK_FILES_FOR_flann::flann "${_IMPORT_PREFIX}/lib/libflann_s.a" )

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)

@xq114
Copy link
Contributor

xq114 commented Jul 28, 2022

改了,现在应该可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants