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

apt安装的libpcl-dev,链接时找不到pcl_in_hand_scanner #2529

Closed
xiaomi2077 opened this issue Jul 4, 2022 · 9 comments
Closed

apt安装的libpcl-dev,链接时找不到pcl_in_hand_scanner #2529

xiaomi2077 opened this issue Jul 4, 2022 · 9 comments
Labels

Comments

@xiaomi2077
Copy link

Xmake 版本

xmake v2.6.8+dev.7d245d6

操作系统版本和架构

Linux ubuntu 5.10.65-tegra #1 SMP PREEMPT Mon May 16 20:58:07 PDT 2022 aarch64 aarch64 aarch64 GNU/Linux

描述问题

使用apt install libpcl-dev 安装 pcl-1.10。链接时报错找不到pcl_in_hand_scanner, pcl_point_cloud_editor

[ 84%]: linking.release liboilfield_all_rules.so
/usr/bin/g++ -o build/linux/arm64-v8a/release/liboilfield_all_rules.so build/.objs/oilfield_all_rules/linux/arm64-v8a/release/rules/all_rules.cpp.o build/.objs/oilfield_all_rules/linux/arm64-v8a/release/rules/rule_impl.cpp.o -shared -fPIC -L3rd_repo/camera_lidar/lib -L3rd_repo/livox_sdk/aarch64/lib -L/usr/local/cuda/lib64 -L/home/ningdr/.xmake/packages/y/yaml-cpp/0.7.0/086d2197d4a140268cdc261a218d6c30/lib -L/home/ningdr/.xmake/packages/f/fmt/8.1.1/de884931b89c45c9827bdfca7369c158/lib -L/home/ningdr/.xmake/packages/j/jsoncpp/1.9.5/26407f9c181546f48ebfe8f13c98455c/lib -Lbuild/linux/arm64-v8a/release -lpcl_apps -lpcl_in_hand_scanner -lpcl_keypoints -lpcl_outofcore -lpcl_people -lpcl_point_cloud_editor -lpcl_recognition -lpcl_registration -lpcl_segmentation -lpcl_features -lpcl_ml -lpcl_stereo -lpcl_surface -lpcl_tracking -lpcl_filters -lpcl_sample_consensus -lpcl_visualization -lpcl_io -lOpenNI -lOpenNI2 -lpcl_search -lpcl_kdtree -llz4 -lflann -lflann_cpp -lpcl_octree -lpcl_common -lopencv_gapi -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lyaml-cpp -lfmt -ljsoncpp -loilfield_common
error: /usr/bin/ld: cannot find -lpcl_in_hand_scanner
/usr/bin/ld: cannot find -lpcl_point_cloud_editor
collect2: error: ld returned 1 exit status

用pkg-config能找到这2个库

$ pkg-config pcl_in_hand_scanner-1.10 --libs --cflags
-I/usr/include/pcl-1.10 -lpcl_in_hand_scanner
$ pkg-config pcl_point_cloud_editor-1.10 --libs --cflags
-I/usr/include/pcl-1.10 -lpcl_point_cloud_editor

期待的结果

能找到缺失的库并链接

工程配置

No response

附加信息和错误日志

No response

@xiaomi2077 xiaomi2077 added the bug label Jul 4, 2022
@waruqi
Copy link
Member

waruqi commented Jul 4, 2022

贴下 xmake.lua 里面 add_requires 配置

然后自己执行下 xmake l find_package apt::libpcl-dev 贴下输出

@xiaomi2077
Copy link
Author

然后自己执行下 xmake l find_package apt::libpcl-dev 贴下输出

$ xmake l find_package apt::libpcl-dev
{ 
  links = { 
    "pcl_apps",
    "pcl_in_hand_scanner",
    "pcl_keypoints",
    "pcl_outofcore",
    "pcl_people",
    "pcl_point_cloud_editor",
    "pcl_recognition",
    "pcl_registration",
    "pcl_segmentation",
    "pcl_features",
    "pcl_ml",
    "pcl_stereo",
    "pcl_surface",
    "pcl_tracking",
    "pcl_filters",
    "pcl_sample_consensus",
    "pcl_visualization",
    "pcl_io",
    "OpenNI",
    "OpenNI2",
    "pcl_search",
    "pcl_kdtree",
    "lz4",
    "flann",
    "flann_cpp",
    "pcl_octree",
    "pcl_common" 
  },
  includedirs = { 
    "/usr/include/pcl-1.10",
    "/usr/include/eigen3",
    "/usr/include/ni",
    "/usr/include/openni2" 
  },
  linkdirs = { } 
}

贴下 xmake.lua 里面 add_requires 配置

add_requires('apt::libpcl-dev')

-- cuda
add_includedirs("/usr/local/cuda/include") --driver_types.h
add_linkdirs('/usr/local/cuda/lib64')


add_requires('ffmpeg','boost','libpng',"yaml-cpp",'fmt',"cxxopts","eigen",{system=false}) -- 不使用系统包
add_requires('opencv',{configs={gtk=true,system=false}})
add_requires('jsoncpp')

-- 公用的函数,yolov5类定义、inference_trt类定义
target('xxx_common')
    set_kind('shared')
    add_files('common/*.cpp')
    add_packages("fmt","opencv",'yaml-cpp','cxxopts')
    add_links('cudart','nvinfer')

-- 规则库
target("xxx_all_rules")
    set_kind("shared")
    add_files('rules/*.cpp')
    add_deps('xxx_common')
    add_packages('apt::libpcl-dev',"opencv","yaml-cpp","fmt","cxxopts",'eigen','jsoncpp')

@xiaomi2077
Copy link
Author

xiaomi2077 commented Jul 4, 2022

是因为linkdirs为空吗?
但是我找apt::libopnecv-dev时也是空,但是opencv的链接库能找到。

$ xmake l find_package apt::libopencv-dev
{ 
  links = { 
    "opencv_gapi",
    "opencv_highgui",
    "opencv_ml",
    "opencv_objdetect",
    "opencv_photo",
    "opencv_stitching",
    "opencv_video",
    "opencv_calib3d",
    "opencv_features2d",
    "opencv_dnn",
    "opencv_flann",
    "opencv_videoio",
    "opencv_imgcodecs",
    "opencv_imgproc",
    "opencv_core" 
  },
  includedirs = { 
    "/usr/include/opencv4" 
  },
  linkdirs = { } 
}

@waruqi
Copy link
Member

waruqi commented Jul 4, 2022

/usr/bin/g++ -o build/linux/arm64-v8a/release/liboilfield_all_rules.so build/.objs/oilfield_all_rules/linux/arm64-v8a/release/rules/all_rules.cpp.o build/.objs/oilfield_all_rules/linux/arm64-v8a/release/rules/rule_impl.cpp.o -shared -fPIC -L3rd_repo/camera_lidar/lib -L3rd_repo/livox_sdk/aarch64/lib -L/usr/local/cuda/lib64 -L/home/ningdr/.xmake/packages/y/yaml-cpp/0.7.0/086d2197d4a140268cdc261a218d6c30/lib -L/home/ningdr/.xmake/packages/f/fmt/8.1.1/de884931b89c45c9827bdfca7369c158/lib -L/home/ningdr/.xmake/packages/j/jsoncpp/1.9.5/26407f9c181546f48ebfe8f13c98455c/lib -Lbuild/linux/arm64-v8a/release
-lpcl_apps -lpcl_in_hand_scanner -lpcl_keypoints -lpcl_outofcore -lpcl_people -lpcl_point_cloud_editor -lpcl_recognition -lpcl_registration -lpcl_segmentation -lpcl_features -lpcl_ml -lpcl_stereo -lpcl_surface -lpcl_tracking -lpcl_filters -lpcl_sample_consensus -lpcl_visualization -lpcl_io -lOpenNI -lOpenNI2 -lpcl_search -lpcl_kdtree -llz4 -lflann -lflann_cpp -lpcl_octree -lpcl_common -lopencv_gapi -lopencv_highgui -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core -lyaml-cpp -lfmt -ljsoncpp -loilfield_common

看你的 link flags,已经完全带上了,没啥问题,你自己确认下 相关符号在那个子库,以及 link 顺序问题

@xiaomi2077
Copy link
Author

是不是pcl库之间顺序的问题?我把apt::libpcl-dev依次向后移动,还是报同样的错误。
它只报错找不到pcl_in_hand_scannerpcl_point_cloud_editor这两个库,其他的库找得到。

error: /usr/bin/ld: cannot find -lpcl_in_hand_scanner
/usr/bin/ld: cannot find -lpcl_point_cloud_editor
collect2: error: ld returned 1 exit status

如何修改pcl库之间的链接顺序呢?

@xiaomi2077
Copy link
Author

好像找到原因了,系统里都没有这2个库。。。那为啥xmake l find_package apt::libpcl-devlinks会把这两个库写上呢?

@waruqi
Copy link
Member

waruqi commented Jul 4, 2022

好像找到原因了,系统里都没有这2个库。。。那为啥xmake l find_package apt::libpcl-devlinks会把这两个库写上呢?

这个你要问 pkg-config 了 ,xmake 也是调用 pkg-config 取的 dpkg --listfiles libpcl-dev 里面的 .pc 文件

@xiaomi2077
Copy link
Author

好了。我把pcl_in_hand_scanner、pcl_point_cloud_editor这2库的pc文件从/usr/lib/aarch64-linux/gnu/pkgconfig里删除了。再xmake f -c,就不再链接这个库了。
还不知道这2库是干啥的,希望我的项目不要用到这2个库。apt安装的有这2个库的pc文件,但是pc文件里写的库文件却不存在,使用find全局查找也找不到,不知道是不是上游打包打错了

@waruqi
Copy link
Member

waruqi commented Jul 4, 2022

不知道,这个跟 xmake 没啥关系了,xmake 也改不了这

@waruqi waruqi closed this as completed Jul 4, 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

2 participants