我使用的是 Ubuntu 18.04,但是对于任何最近的 Linux 发行版来说,这个问题应该几乎相同。
基于这篇文章:
我正在尝试从源代码构建点云库,如下所示:
安装各种软件包:
sudo apt-get -y install g++ cmake cmake-gui doxygen mpi-default-dev openmpi-bin openmpi-common
sudo apt-get -y install libusb-1.0-0-dev libqhull* libusb-dev libgtest-dev
sudo apt-get -y install git-core freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev
sudo apt-get -y install libphonon-dev libphonon-dev phonon-backend-gstreamer
sudo apt-get -y install phonon-backend-vlc graphviz mono-complete
sudo apt-get -y install qt5-default
sudo apt-get -y install libflann-dev
sudo apt-get -y install libflann1.9
sudo apt-get -y install libboost-dev
sudo apt-get -y install libeigen3-dev
编译并安装VTK 8.1.1:
cd ~/Downloads
wget http://www.vtk.org/files/release/8.1/VTK-8.1.1.tar.gz
tar -zxvf VTK-8.1.1.tar.gz
cd VTK-8.1.1
mkdir build
cd build
cmake ..
make
sudo make install
编译并安装PCL 1.8.1
cd ~/Downloads
wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz
tar -zxvf pcl-1.8.1.tar.gz
cd pcl-pcl-1.8.1
mkdir build
cd build
cmake ..
make
sudo make install
运行 ldconfig
sudo ldconfig
这很好用,但是默认情况下 PCL 示例未设置为编译,我真的希望能够运行这些示例。 参考这篇文章后:
我按照上面的步骤进行,只有在去皮PCL之后,我才打开文件
~/Downloads/pcl-pcl-1.8.1/CMakeLists.txt
我对
example
执行了 Ctrl-F 操作,发现了以下几行:
### ---[ Set up for examples
#include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake")
接下来我删除了这两行第二行开头的注释字符 #,所以现在我有:
### ---[ Set up for examples
include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake")
继续上述步骤,当我做
cmake ..
时,我现在得到:
~/Downloads/pcl-pcl-1.8.1/build$ cmake ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.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")
-- 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
-- -- GCC > 4.3 found, enabling -Wabi
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found OpenMP
-- Checking for module 'eigen3'
-- Found eigen3, version 3.3.4
-- Found Eigen: /usr/include/eigen3
-- Eigen found (include: /usr/include/eigen3, version: 3.3.4)
-- Checking for module 'flann>=1.7.0'
-- Found flann, version 1.9.1
-- Found FLANN: /usr/lib/x86_64-linux-gnu/libflann_cpp.so (Required is at least version "1.7.0")
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libflann_cpp.so;debug;/usr/lib/x86_64-linux-gnu/libflann_cpp.so)
-- 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.21
-- Found USB_10: /usr/lib/x86_64-linux-gnu/libusb-1.0.so
-- Could NOT find OpenNI (missing: OPENNI_LIBRARY OPENNI_INCLUDE_DIR)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
OpenNI grabber support: not building because OpenNI not found
Call Stack (most recent call first):
CMakeLists.txt:296 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIRS)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
OpenNI2 grabber support: not building because OpenNI2 not found
Call Stack (most recent call first):
CMakeLists.txt:297 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find FZAPI (missing: FZAPI_LIBS FZAPI_INCLUDE_DIRS)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
Fotonic camera support: not building because FZAPI not found
Call Stack (most recent call first):
CMakeLists.txt:298 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find ensenso (missing: ENSENSO_LIBRARY ENSENSO_INCLUDE_DIR)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
IDS-Imaging Ensenso camera support: not building because Ensenso not found
Call Stack (most recent call first):
CMakeLists.txt:299 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find davidSDK (missing: DAVIDSDK_LIBRARY DAVIDSDK_INCLUDE_DIR)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
David Vision Systems SDK support: not building because davidSDK not found
Call Stack (most recent call first):
CMakeLists.txt:300 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find DSSDK (missing: DSSDK_LIBRARIES DSSDK_INCLUDE_DIRS)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
DepthSense SDK support: not building because DSSDK not found
Call Stack (most recent call first):
CMakeLists.txt:301 (PCL_ADD_GRABBER_DEPENDENCY)
-- Could NOT find RSSDK (missing: RSSDK_LIBRARIES RSSDK_INCLUDE_DIRS)
CMake Warning at cmake/pcl_targets.cmake:864 (message):
RealSense SDK support: not building because RSSDK not found
Call Stack (most recent call first):
CMakeLists.txt:302 (PCL_ADD_GRABBER_DEPENDENCY)
-- Checking for module 'metslib'
-- No package 'metslib' found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version "1.6.34")
-- Found Qhull: /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)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA Toolkit v9.2
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_53,code=sm_53;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61
-- VTK_MAJOR_VERSION 8, rendering backend: OpenGL2
-- VTK found (include: /usr/local/include/vtk-8.1, lib: vtksys;vtkCommonCore;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonDataModel;vtkCommonColor;vtkCommonExecutionModel;vtkCommonComputationalGeometry;vtkFiltersCore;vtkFiltersGeneral;vtkImagingCore;vtkImagingFourier;vtkalglib;vtkFiltersStatistics;vtkFiltersExtraction;vtkInfovisCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingCore;vtkzlib;vtkfreetype;vtkRenderingFreeType;vtkRenderingContext2D;vtkChartsCore;vtkDICOMParser;vtklz4;vtkIOCore;vtkIOLegacy;vtkexpat;vtkIOXMLParser;vtkDomainsChemistry;vtkglew;vtkRenderingOpenGL2;vtkDomainsChemistryOpenGL2;vtkIOXML;vtkParallelCore;vtkFiltersAMR;vtkFiltersFlowPaths;vtkFiltersGeneric;vtkImagingSources;vtkFiltersHybrid;vtkFiltersHyperTree;vtkImagingGeneral;vtkFiltersImaging;vtkFiltersModeling;vtkFiltersParallel;vtkFiltersParallelImaging;vtkFiltersPoints;vtkFiltersProgrammable;vtkFiltersSMP;vtkFiltersSelection;vtkFiltersTexture;vtkFiltersTopology;verdict;vtkFiltersVerdict;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkIOImage;vtkImagingHybrid;vtkInfovisLayout;vtkInteractionStyle;vtkImagingColor;vtkRenderingAnnotation;vtkRenderingVolume;vtkInteractionWidgets;vtkViewsCore;vtkproj4;vtkGeovisCore;vtkhdf5_hl;vtkhdf5;vtkIOAMR;vtkIOEnSight;vtkNetCDF;vtkexoIIc;vtkIOExodus;vtkgl2ps;vtkRenderingGL2PSOpenGL2;vtklibharu;vtkIOExport;vtkIOExportOpenGL2;vtkIOGeometry;vtkIOImport;vtklibxml2;vtkIOInfovis;vtkIOLSDyna;vtkIOMINC;vtkoggtheora;vtkIOMovie;vtknetcdfcpp;vtkIONetCDF;vtkIOPLY;vtkjsoncpp;vtkIOParallel;vtkIOParallelXML;vtksqlite;vtkIOSQL;vtkIOTecplotTable;vtkIOVideo;vtkImagingMath;vtkImagingMorphological;vtkImagingStatistics;vtkImagingStencil;vtkInteractionImage;vtkRenderingContextOpenGL2;vtkRenderingImage;vtkRenderingLOD;vtkRenderingLabel;vtkRenderingVolumeOpenGL2;vtkViewsContext2D;vtkViewsInfovis
-- Could NOT find PCAP (missing: PCAP_LIBRARIES PCAP_INCLUDE_DIRS)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
-- system
-- filesystem
-- thread
-- date_time
-- iostreams
-- chrono
-- atomic
-- regex
CMake Error at CMakeLists.txt:431 (include):
include could not find load file:
/home/cdahms/Downloads/pcl-pcl-1.8.1/cmake/pcl_examples.cmake
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- DOXYGEN_FOUND
-- HTML_HELP_COMPILER
-- Found CPack generators: DEB
-- The following subsystems will be built:
-- common
-- octree
-- io
-- kdtree
-- search
-- sample_consensus
-- filters
-- 2d
-- geometry
-- features
-- ml
-- segmentation
-- visualization
-- surface
-- registration
-- keypoints
-- tracking
-- recognition
-- stereo
-- outofcore
-- people
-- tools
-- The following subsystems will not be built:
-- apps: No reason
-- examples: Code examples are disabled by default.
-- simulation: Disabled by default.
-- global_tests: No reason
-- Configuring incomplete, errors occurred!
由于
cmake ..
步骤没有成功,所以现在当我这样做时make
我得到:
$ make
make: *** No targets specified and no makefile found. Stop.
我想除了取消注释
include("${PCL_SOURCE_DIR}/cmake/pcl_examples.cmake")
中的 CMakeLists.txt
行之外,肯定还有其他设置? 有人可以告知成功编译示例所需的额外步骤吗?
在您的
cmake
命令中,请添加 -DBUILD_examples=ON
作为启用示例的选项。
我遇到了类似的
The PATH argument is required
问题。我的解决方案来自使用 VTK 依赖项配置软件时的问题 - VTK cmake 文件中失败。
我的错误信息如下
CMake Error at /usr/local/lib/cmake/vtk-9.1/vtkDetectLibraryType.cmake:23 (message):
The `PATH` argument is required.
Call Stack (most recent call first):
/usr/local/lib/cmake/vtk-9.1/FindFreetype.cmake:179 (vtk_detect_library_type)
/usr/local/lib/cmake/vtk-9.1/patches/3.19/FindX11.cmake:235 (find_package)
/usr/local/lib/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:350 (find_package)
/usr/local/lib/cmake/vtk-9.1/vtk-config.cmake:152 (include)
CMakeLists.txt:366 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/user/sourcecode/pcl-1.9.1/build/CMakeFiles/CMakeOutput.log".
从错误信息来看,是
vtkDetectLibraryType.cmake:23
破坏了程序。 vtkDetectLibraryType.cmake:23
的上下文如下:
function (vtk_detect_library_type output)
cmake_parse_arguments(PARSE_ARGV 1 vdlt
""
"PATH"
"")
if (NOT DEFINED vdlt_PATH)
message(FATAL_ERROR
"The `PATH` argument is required.") # <------ error occurs here
endif ()
if (DEFINED vdlt_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"Unparsed arguments for vtk_detect_library_type: "
"${vdlt_UNPARSED_ARGUMENTS}")
endif ()
从代码来看,只有当
vdlt_PATH
没有定义时,程序才会退出并输出The PATH argument is required
。
vdlt_PATH
是如何定义的?这是由cmake_parse_arguments
完成的。它解析参数,检查是否包含 PATH
关键字并将值相应地存储到 vdlt_PATH
。
从调用堆栈中,我们可以看到是
FindFreetype.cmake:179
导致了vtkDetectLibraryType.cmake:23
。 FindFreetype.cmake:179
的内容是:
vtk_detect_library_type(freetype_release_library_type
PATH "${FREETYPE_LIBRARY_RELEASE}")
只需在相关函数中传递
${FREETYPE_LIBRARY_RELEASE}
和 ${argv1}
的值,输出都是相同的。
因此,在我的情况下,
cmake_parse_arguments
似乎无法正常工作。因此,我们可以手动设置 cmake_parse_arguments
的值,而不是使用 vdlt_PATH
,如下所示:
function (vtk_detect_library_type output)
list(GET ARGN 1 ARGN1)
set(vdlt_PATH ${ARGN1})
if (NOT DEFINED vdlt_PATH)
message(FATAL_ERROR
"The `PATH` argument is required.")
endif ()