装这两个库真的是要吐了, 本文不教装环境,仅仅记录本人在装环境过程中出现的关键问题
liblas和PCL的安装就不多说了,网上教程一大堆,最重要的要了解有什么依赖库再动手,比如说boost,eigen,VTK,numpy,cmake等等一大堆,先装依赖库,装好了之后再去编译源码,关于PCL库没啥好说的,就是依赖库装好按着流程来就行了。
推荐链接:https://blog.csdn.net/sinat_28752257/article/details/79169647
在安装pcl的过程中,cmake…之后可以检查你的库是否能正常找到:
– The C compiler identification is GNU 5.4.0
– The CXX compiler identification is GNU 5.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found PkgConfig: /usr/bin/pkg-config (found version “0.29.1”)
– Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE ClangFormat_VERSION) (Required is at least version “10”)
– Performing Test HAVE_MARCH
– Performing Test HAVE_MARCH - Success
– Using CPU native flags for SSE optimization: -march=native
– Performing Test HAVE_MM_MALLOC
– Performing Test HAVE_MM_MALLOC - Success
– Performing Test HAVE_POSIX_MEMALIGN
– Performing Test HAVE_POSIX_MEMALIGN - Success
– Performing Test HAVE_SSE4_2_EXTENSIONS
– Performing Test HAVE_SSE4_2_EXTENSIONS - Success
– Performing Test HAVE_SSE4_1_EXTENSIONS
– Performing Test HAVE_SSE4_1_EXTENSIONS - Success
– Performing Test HAVE_SSSE3_EXTENSIONS
– Performing Test HAVE_SSSE3_EXTENSIONS - Success
– Performing Test HAVE_SSE3_EXTENSIONS
– Performing Test HAVE_SSE3_EXTENSIONS - Success
– Performing Test HAVE_SSE2_EXTENSIONS
– Performing Test HAVE_SSE2_EXTENSIONS - Success
– Performing Test HAVE_SSE_EXTENSIONS
– Performing Test HAVE_SSE_EXTENSIONS - Success
– Try OpenMP C flag = [-fopenmp]
– Performing Test OpenMP_FLAG_DETECTED
– Performing Test OpenMP_FLAG_DETECTED - Success
– Try OpenMP CXX flag = [-fopenmp]
– Performing Test OpenMP_FLAG_DETECTED
– Performing Test OpenMP_FLAG_DETECTED - Success
– Found OpenMP: -fopenmp
– Found OpenMP
– Looking for pthread.h
– Looking for pthread.h - found
– Looking for pthread_create
– Looking for pthread_create - found
– Found Threads: TRUE
– Checking for module ‘eigen3’
– Found eigen3, version 3.2.92
– Found Eigen: /usr/include/eigen3 (Required is at least version “3.1”)
– Eigen found (include: /usr/include/eigen3, version: 3.2.92)
– Checking for module ‘flann>=1.7.0’
– Found flann, version 1.8.4
– Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp.so (Required is at least version “1.7.0”)
– Found LIBUSB_1: /usr/lib/x86_64-linux-gnu/libusb-1.0.so
– Checking for module ‘libusb-1.0’
– Found libusb-1.0, version 1.0.20
– Found USB_10: /usr/lib/x86_64-linux-gnu/libusb-1.0.so
– Found OpenNI: /usr/lib/libOpenNI.so
– OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so)
– Could NOT find OpenNI2 (missing: OPENNI2_LIBRARIES OPENNI2_INCLUDE_DIRS)
– OpenNI2 grabber support: not building because OpenNI2 not found
– Could NOT find ENSENSO (missing: ENSENSO_LIBRARIES ENSENSO_INCLUDE_DIRS)
– IDS-Imaging Ensenso camera support: not building because Ensenso not found
– Could NOT find davidSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR)
– David Vision Systems SDK support: not building because davidSDK not found
– Could NOT find DSSDK (missing: DSSDK_LIBRARIES DSSDK_INCLUDE_DIRS)
– DepthSense SDK support: not building because DSSDK not found
– Could NOT find RSSDK (missing: RSSDK_LIBRARIES RSSDK_INCLUDE_DIRS)
– RealSense SDK support: not building because RSSDK not found
– Could NOT find RSSDK2
– RealSense SDK 2.0 (librealsense) support: not building because RSSDK2 not found
– Checking for module ‘metslib’
– No package ‘metslib’ found
– Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version “1.2.8”)
– Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version “1.2.54”)
– Found Qhull: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so
– QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
– VTK_MAJOR_VERSION 7, rendering backend: OpenGL2
– VTK found (include: /usr/local/include/vtk-7.1, libs: vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;vtkfreetype;vtkzlib;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;vtkexpat;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2;vtkglew
– Found PCAP: /usr/lib/x86_64-linux-gnu/libpcap.so
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:26 (find_package)
CMakeLists.txt:460 (include)
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:26 (find_package)
CMakeLists.txt:460 (include)
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:33 (find_package)
CMakeLists.txt:460 (include)
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:33 (find_package)
CMakeLists.txt:460 (include)
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:33 (find_package)
CMakeLists.txt:460 (include)
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
Imported targets not available for Boost version 107300
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
cmake/pcl_find_boost.cmake:33 (find_package)
CMakeLists.txt:460 (include)
– Boost version: 1.73.0
– Found the following Boost libraries:
– filesystem
– date_time
– iostreams
– system
– Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
– Found GLEW: /usr/include
– DOXYGEN_FOUND
– HTML_HELP_COMPILER
– Found CPack generators: DEB
– The following subsystems will be built:
– common
– kdtree
– octree
– search
– sample_consensus
– filters
– 2d
– features
– io
– geometry
– visualization
– ml
– segmentation
– people
– keypoints
– surface
– stereo
– registration
– recognition
– tracking
– outofcore
– tools
– The following subsystems will not be built:
– global_tests: Disabled by default
– examples: Code examples are disabled by default.
– simulation: Disabled by default.
– apps: Disabled by default
– Configuring done
– Generating done
– Build files have been written to: /home/wuyu/env/pcl-master/build
在编译liblas的过程中存在着比较致命的问题,我从github上面下载的源码,你可能存在的问题主要有以下两个,其他的我认为都是依赖库没装好的原因,每次出错要认真阅读错误并分析原因:
可以参见我的博客:解决cmake Policy CMP0057 is not set: Support new IN_LIST if() operator
https://blog.csdn.net/Woosual/article/details/106682989
Ubuntu 16.04, libLAS 1.8.1, Error while building at boost::bind…
这个是跟boost库有关,这个问题可以在liblas的issue中找到
https://github.com/libLAS/libLAS/issues/186
你出现的问题可能是这样的:
[ 1%] Building CXX object src/CMakeFiles/las.dir/header.cpp.o
/home/yuksel/Downloads/liblas/src/header.cpp: In copy constructor ‘liblas::Header::Header(const liblas::Header&)’:
/home/yuksel/Downloads/liblas/src/header.cpp:104:11: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
void* p = 0;
^
/home/yuksel/Downloads/liblas/src/header.cpp: In member function ‘liblas::Header& liblas::Header::operator=(const liblas::Header&)’:
/home/yuksel/Downloads/liblas/src/header.cpp:123:15: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
void* p = 0;
^
/home/yuksel/Downloads/liblas/src/header.cpp: In member function ‘void liblas::Header::DeleteVLRs(const string&, uint16_t)’:
/home/yuksel/Downloads/liblas/src/header.cpp:613:69: error: ‘1’ was not declared in this scope
boost::bind( &SameVLRs, name, id, 1 ) ),
^
/home/yuksel/Downloads/liblas/src/header.cpp:613:69: note: suggested alternatives:
In file included from /usr/local/include/boost/mpl/aux/include_preprocessed.hpp:37:0,
from /usr/local/include/boost/mpl/placeholders.hpp:43,
from /usr/local/include/boost/mpl/apply.hpp:24,
from /usr/local/include/boost/mpl/aux/iter_apply.hpp:17,
from /usr/local/include/boost/mpl/aux_/find_if_pred.hpp:14,
from /usr/local/include/boost/mpl/find_if.hpp:17,
from /usr/local/include/boost/mpl/find.hpp:17,
from /usr/local/include/boost/mpl/aux_/contains_impl.hpp:20,
from /usr/local/include/boost/mpl/contains.hpp:20,
from /usr/local/include/boost/multi_index_container.hpp:26,
from /home/yuksel/Downloads/liblas/include/liblas/external/property_tree/ptree.hpp:21,
from /home/yuksel/Downloads/liblas/include/liblas/schema.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/point.hpp:47,
from /home/yuksel/Downloads/liblas/include/liblas/bounds.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/header.hpp:47,
from /home/yuksel/Downloads/liblas/src/header.cpp:43:
/usr/local/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp:29:16: note: ‘mpl_::1’
typedef arg<1> 1;
^
/usr/local/include/boost/mpl/aux/preprocessed/gcc/placeholders.hpp:29:16: note: ‘mpl::1’
In file included from /usr/local/include/boost/bind/bind.hpp:2356:0,
from /usr/local/include/boost/multi_index/sequenced_index.hpp:17,
from /home/yuksel/Downloads/liblas/include/liblas/external/property_tree/ptree.hpp:23,
from /home/yuksel/Downloads/liblas/include/liblas/schema.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/point.hpp:47,
from /home/yuksel/Downloads/liblas/include/liblas/bounds.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/header.hpp:47,
from /home/yuksel/Downloads/liblas/src/header.cpp:43:
/usr/local/include/boost/bind/placeholders.hpp:46:38: note: ‘boost::placeholders::1’
BOOST_STATIC_CONSTEXPR boost::arg<1> 1;
^
In file included from /usr/local/include/boost/lambda/lambda.hpp:14:0,
from /home/yuksel/Downloads/liblas/src/header.cpp:56:
/usr/local/include/boost/lambda/core.hpp:71:60: note: ‘boost::lambda::{anonymous}::1’
boost::lambda::placeholder1_type& BOOST_ATTRIBUTE_UNUSED 1 = free1;
^
/usr/local/include/boost/lambda/core.hpp:71:60: note: ‘boost::lambda::{anonymous}::1’
In file included from /usr/local/include/boost/mpl/aux/include_preprocessed.hpp:37:0,
from /usr/local/include/boost/mpl/placeholders.hpp:43,
from /usr/local/include/boost/mpl/apply.hpp:24,
from /usr/local/include/boost/mpl/aux/iter_apply.hpp:17,
from /usr/local/include/boost/mpl/aux/find_if_pred.hpp:14,
from /usr/local/include/boost/mpl/find_if.hpp:17,
from /usr/local/include/boost/mpl/find.hpp:17,
from /usr/local/include/boost/mpl/aux/contains_impl.hpp:20,
from /usr/local/include/boost/mpl/contains.hpp:20,
from /usr/local/include/boost/multi_index_container.hpp:26,
from /home/yuksel/Downloads/liblas/include/liblas/external/property_tree/ptree.hpp:21,
from /home/yuksel/Downloads/liblas/include/liblas/schema.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/point.hpp:47,
from /home/yuksel/Downloads/liblas/include/liblas/bounds.hpp:46,
from /home/yuksel/Downloads/liblas/include/liblas/header.hpp:47,
from /home/yuksel/Downloads/liblas/src/header.cpp:43:
/usr/local/include/boost/mpl/aux/preprocessed/gcc/placeholders.hpp:29:16: note: ‘mpl::_1’
typedef arg<1> _1;
^
src/CMakeFiles/las.dir/build.make:199: recipe for target ‘src/CMakeFiles/las.dir/header.cpp.o’ failed
make[2]: *** [src/CMakeFiles/las.dir/header.cpp.o] Error 1
CMakeFiles/Makefile2:273: recipe for target ‘src/CMakeFiles/las.dir/all’ failed
make[1]: *** [src/CMakeFiles/las.dir/all] Error 2
Makefile:182: recipe for target ‘all’ failed
make: *** [all] Error 2
源码作者也给出了相应的解决方法:
但是需要注意的是,你修改了这个地方之后还会报错,因为在代码的其他地方编译错误也是这个原因引起的,你还需要自己查看错误,分析是哪出错需要加上上面两句代码。
这个由于我是第一次实际要用到动态连接库,之前对编译过程也知道,但实际应用还是出现了问题
比如我运行以下代码:
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace liblas;
int main()
{
//确定las文件输入路径以及pcd文件输出路径
//const char* lasfile = "data.las";
string lasfile = "data.las";
//string lasfile = "data.las"
//const char* pcdfile = "out_data.pcd";
string pcdfile = "out_data.pcd";
std::ifstream ifs;
ifs.open(lasfile, std::ios::in | std::ios::binary);
//liblas::ReaderFactory f;
ReaderFactory f;
Reader reader = f.CreateWithStream(ifs);
//liblas::Reader reader = f.CreateWithStream(ifs);
//liblas::Header const& header = reader.GetHeader();
//liblas::Header header = reader.GetHeader();
Header header = reader.GetHeader();
pcl::PointCloud<pcl::PointXYZ>::Ptr pointCloudPtr(new pcl::PointCloud<pcl::PointXYZ>);
int count = header.GetPointRecordsCount();
pointCloudPtr->resize(count);
pointCloudPtr->width = 1;
pointCloudPtr->height = count;
pointCloudPtr->is_dense = false;
int i = 0;
while (reader.ReadNextPoint())
{
//liblas::Point const& p = reader.GetPoint();
//liblas::Point p = reader.GetPoint();
Point p = reader.GetPoint();
//pointCloudPtr->points[i].x = p.GetX();
pointCloudPtr->points[i].x = p.GetX();
pointCloudPtr->points[i].y = p.GetY();
pointCloudPtr->points[i].z = p.GetZ();
++i;
}
pcl::io::savePCDFileASCII(pcdfile,*pointCloudPtr);
return 0;
}
出现了未定义引用错误 undefined reference to 某某函数,这个问题就是动态链接库没引进去,一般来说你安装好的liblas、boost、pcl库都在/usr/local/include或/usr/include/下面可以找到头文件,可以在相应的lib中找到动态链接库文件,我最后解决方法是这样的:
解决了库找不到的问题,由于动态库就在系统的include目录中,因此直接用-l命令引入就好,在lib中,比如说我用到了liblas.so.3这个动态连接库,那么编译的时候加-llas就好, 去掉lib和后面的.so
附上:Linux程序运行找不到动态库.so文件的三种解决办法
https://blog.csdn.net/u010333084/article/details/86506361