对于直接安装或解压的程序,除git, cmake, cuda按默认路径安装外,其它程序都安装在D:\app\softname
对于编译安装的程序,都安装在D:\app\softname\build\install
对于ubuntu可首先直接从源安装以下包,之后就只剩下cuda, qt, openni2需要直接安装,其余都编译安装
0.基本开发工具
0.1git&cmake&cuda
(1)win安装:安装路径默认,自动追加path环境变量 (2)ubuntu安装:git, cmake3, cmake3-qt-gui, {cuda} |
0.2python&doxygen&hdf5
(1)win安装:安装路径D:\app\softname,自动追加path环境变量 (2)ubuntu安装:python3, doxygen, libhdf5-dev |
0.3openni2&tbb&qt&boost
(1)win安装:安装路径D:\app\softname,手动追加path环境变量 D:/app/openni2/Redist D:/app/tbb/bin/intel64/vc14 D:/app/qt/5.6/msvc2015_64/bin到Path头(非常重要) D:/app/boost/lib64-msvc-14.0 boost库操作:删除D:/app/boost/lib64-msvc-14.0中满足*gd*.lib boost编译文件在win上的命名:lib静态库,vcx编译器版本,mt多线程编译,d调试版本 (2)ubuntu安装:libtbb-dev, libboost-all-dev, {openni2, qt} 解压/root/app/opennni2查看install.h可知将primesense-usb.rules复制重命名为/etc/udev/rules.d/557-primesense-usb.rules |
1.数学相关库
1.1suitesparse
(1)win编译 OPENMP=ON BUILD_METIS=ON EXPORT_USE_INTERFACE_LINK_LIBRARIES=ON SUITESPARSE_USE_CUSTOM_BLAS_LAPACK_LIBS=ON UITESPARSE_CUSTOM_BLAS_LIB=D:/app/suitesparse/lapack_windows/x64/libblas.lib SUITESPARSE_CUSTOM_LAPACK_LIB=D:/app/suitesparse/lapack_windows/x64/liblapack.lib SUITESPARSE_INSTALL_PREFIX=D:/app/suitesparse/build/install Path添加D:/app/suitesparse/lapack_windows/x64 关于suitesparse,它由经典算法和csparse及cxsparse组 经典算法依赖lapack和blas(suitesparse-metis包内已含win依赖),效率高。 csparse不依赖lapack和blas,但效率低。 cxsparse是csparse超集,扩展支持复数和整型及长整型,用csparse的地方都可用之替换。 另外,容易分不清lapack和lapacke,lapacke是c接口的lapack,因为blas和lapack本身是用fortan语言写的。 (2)ubuntu编译 从源安装lapack及依赖,并将安装后的libblas.a和liblapack.a复制到/root/app/suitesparse/lapack_windows/u64,然后自卸载安装 其它与win相似,环境变量 |
1.2eigen&sophus
无需编译,直接包含头文件即可 |
1.3ceres&glog&gflags
(1)win编译gflags 解压后先删除BUILD,否则无法新建build目录 CMAKE_INSTALL_PREFIX=D:/app/gflags/build/install (2)win编译glog gflags_DIR=D:/app/gflags/build/install/lib/cmake/gflags CMAKE_INSTALL_PREFIX=D:/app/glog/build/install (3)win编译ceres OPENMP=ON EIGENSPARSE=ON CXSPARSE=ON GFLAGS=ON EXPORT_BUILD_DIR=ON SCHUR_USE_STATIC_CRT=ON BUILD_TESTING=ON EIGEN_INCLUDE_DIR=D:/app/eigen gflags_DIR=D:/app/gflags/build/install/lib/cmake/gflags glog_DIR=D:/app/glog/build/install/lib/cmake/glog CXSPARSE_INCLUDE_DIR=D:/app/suitesparse/build/install/include/suitesparse CXSPARSE_LIBRARY=D:/app/suitesparse/build/install/lib/libcxsparse.lib CMAKE_INSTALL_PREFIX=D:/app/ceres/build/install (4)ubuntu编译ceres:与win相似 |
2.opencv相关
2.1opencv
(1)win编译 1)OPENCV赋值 D:\app\opencv\contribs\modules\cvv\src\stfl\stringutils.cpp将其中u8”…”修改为u8”...” OPENCV_CONFIG_FILE_INCLUDE_DIR=D:/app/opencv/build OPENCV_DOWNLOAD_PATH=D:/app/opencv/sources/.cache OPENCV_ENABLE_NONFREE=ON OPENCV_EXTRA_MODULES_PATH=D:/app/opencv/contribs/modules OPENCV_WARNINGS_ARE_ERRORS=OFF 2)WITH全选:这样可引出所有第三方项(但WITH_CU*移除),不能提供的第三项opencv将自动禁用从而保证编译不出错 本地提供项:git, cuda, python3, doxygen, hdf5, openni2, tbb, qt, eigen, ceres&glog&gflag, vtk, openvx 实时下载项:ffmpeg(dll音视频编解码), ippicv(lib&inc并行库), tbb接口(inc&src并行库但对win无效) tiny_dnn(inc&src卷积神经网络), xfeatures2d(训练好的神经网络模型) 位置D:\app\opencv\sources\.cache 编译源码项:图像编解码(libjasper, libjeg, libpng, jlibtiff, ligwebp, openxr), 数据压缩zlib, 数据格式protobuf 内存监控ittnotify 3)BUILD排除:_CUDA_STUBS, _DOCS, _EXAMPLES, _TBB(本地提供), _opencv_cuda, _opencv_cudev, _world, _contrib_world 4)3rdlib重用:复制D:\app\opencv\build\3rdparty\lib\Release\*.lib(没含ffmpeg和ippicv)到D:\app\opencv\sources\3rdparty\lib 复制D:\app\hdf5\include\zconf.h到D:\app\opencv\sources\3rdparty\zlib (2)ubuntu编译:与win相似,但BUILD还关闭_JASPER, _JPEG, _OPENEXR, _PNG, _TIFF, _ZLIB, _PROTOBUF(?), 因为已安装 1)可能会提示nullptr问题,此时打开相应的文件将nullptr改为NULL即可 2) |
2.2vtk
(1)win编译 CMAKE_INSTALL_PREFIX=D:/app/vtk/build/install INSTALL_BIN_DIR=D:/app/vtk/build/install/bin INSTALL_INC_DIR=D:/app/vtk/build/install/include INSTALL_LIB_DIR=D:/app/vtk/build/install/lib INSTALL_MAN_DIR=D:/app/vtk/build/install/share/man INSTALL_PKGCONFIG_DIR=D:/app/vtk/build/install/share/pkgconfig Path增加D:/app/vtk/build/install/bin (2)ubuntu编译 |
3.pcl相关
3.1pcl
(1)win编译 1)PCL赋值 CMakeLists添加set(BOOST_ROOT D:/app/boost) 为ON的:_ENABLE_SSE, _SHEARD_LIBS 2)WITH全选:这样可引出所有第三方项(但_CUDA和_DOCS移除),不能提供的第三项pcl将自动禁用从而保证编译不出错 本地提供项:doxygen, python, zlib, png, qhull, flann, boost, qt, vtk, eigen PNG_PNG_INCLUDE_DIR=D:/app/opencv/sources/3rdparty/libpng PNG_LIBRARY_RELEASE=D:/app/opencv/sources/3rdparty/lib/libpng.lib ZLIB_INCLUDE_DIR=D:/app/opencv/sources/3rdparty/zlib ZLIB_LIBRARY_RELEASE=D:/app/opencv/sources/3rdparty/lib/zlib.lib 3)BUILD排除:_CUDA, _GPU, _all_in_one_installer, _apps, _examples, _global_tests 4)其它注意项: INSTALL_BIN_DIR=D:/app/pcl/build/install USE_PROJECT_FOLDERS=ON CUDA相关全OFF (2)ubuntu编译 |
3.2flann
(1)win编译 USE_OPENMP=ON BUILD_DOC=OFF BUILD_EXAMPLES=OFF BUILD_CUDA_LIB=OFF BUILD_MATLAB_BINDINGS=OFF BUILD_PYTHON_BINDINGS=OFF BUILD_CUDA_LIB=OFF HDF5_DIR=D:/app/hdf5/cmake HDF5_DIFF_EXECUTABLE=D:/app/hdf5/bin/h5diff.exe PYTHON_EXECUTABLE=D:/app/python/python.exe INSTALL_BIN_DIR=D:/app/flann/build/install Path增加D:/app/flann/build/install/bin (2)ubuntu编译 |
3.3qhull
(1)win编译 删除D:/app/qhull/bin和D:/app/qhull/build/* WITH_LFS=ON INSTALL_BIN_DIR=D:/app/qhull/build/install Path增加D:/app/qhull/build/install/bin (2)ubuntu编译 |
5.vslam相关
5.1g2o
(1)win编译 删除D:/app/g2o/EXTERNAL/csparse(使用编译好csparse执行) BUILD_LGPL_SHARED_LIBS=ON BUILD_SHARED_LIBS=ON G2O_USE_OPENGL=ON G2O_USE_OPENPM=ON EIGEN_INCLUDE_DIR=D:/app/eigen QT_XXX=… CMAKE_INSTALL_PREFIX=D:/app/g2o/build/install CSPARSE_INCLUDE_DIR=D:/app/suitesparse/build/install/include/suitesparse(使用编译好csparse执行) CSPARSE_LIBRARY=D:/app/suitesparse/build/install/lib/libcxsparse.lib(使用编译好csparse执行) Path添加D:/app/g2o/build/install/bin 自建D:/app/suitesparse/build/install/G2OConfig.cmake get_filename_component(_G2O_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(G2O_INCLUDE_DIR ${_G2O_SELF_DIR}/include) file(GLOB G2O_LIBS ${_G2O_SELF_DIR}/lib/*.lib) set(G2O_FOUND TRUE) unset(_G2O_SELF_DIR) 若不使用编译好的csparse则g2o和suitesparse不能同时配置,否则会冲突 (2)ubuntu编译 |
5.2octomap
(1)win编译 OCTOMAP_OMP=ON OCTOVIS_QT5=ON BUILD_DYNAMICETD3D_SUBPROJECT=ON BUILD_OCTOVIS_SUBPROJECT=ON BUILD_TESTING=ON QT_QMAKE_EXECUTABLE= D:/app/qt/5.6/msvc2015_64/bin/qmake.exe QGLVIEWER_BASE_DIR= D:/app/octomap/octovis/src/extern/QGLViewer QGLViewer_INCLUDE_DIR= D:/app/octomap/octovis/src/extern/QGLViewer DOXYGEN_EXECUTABLE= D:/app/doxygen/bin/doxygen.exe CMAKE_INSTALL_PREFIX=D:/app/octomap/build/install (2)ubuntu编译 |
5.3gtsam
(1)win编译 打开CMakeLists添加:set(BOOST_ROOT D:/app/boost) GTSAM_WITH_EIGEN_MKL=OFF GTSAM_WITH_EIGEN_MKL_OPENMP=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=OFF TBB_INSTALL_DIR=D:/app/tbb TBB_INCLUDE_DIR=D:/app/tbb/include TBB_INCLUDE_DIRS=D:/app/tbb/include TBB_LIBRARY_DIRS=D:/app/tbb/lib/intel64/vc14 TBB_LIBRARY=D:/app/tbb/lib/intel64/vc14/tbb.lib TBB_MALLOC_LIBRARY=D:/app/tbb/lib/intel64/vc14/tbbmalloc.lib CMAKE_INSTALL_PREFIX=D:/app/gstam/build/install DOXYGEN_EXECUTABLE=D:/app/doxygen/bin/doxygen.exe GITCOMMAND=C:/Program Files/Git/cmd/git.exe Boost_XXX_RELEASE=D:/app/boost/lib64-msvc-14.0/boost_xxx-vc140-mt-1_64.lib Boost_XXX_DEBUG=D:/app/boost/lib64-msvc-14.0/boost_xxx-vc140-mt-gd-1_64.lib Path添加D:\app\gtsam\build\install\bin; (2)ubuntu编译 |
5.4pangolin
(1)win编译 1)WITH项 本地提供项:git, doxygen, tiff, openexr, openni2, eigen, 未提供ffmpeg(avcodec&avformat&swscale)和openexr 实时下载项:glew(inc&src), libjepg(inc&src), libpng(inc&src), zlib(inc&src) 2)BUILD为OFF:_EXAMPLES 3)其它注意项: OpenEXR_INCLUDE_DIR= D:/app/opencv/sources/3rdparty/openexr/IlmImf;~/openexr/Imath;~\3rdparty\openexr\Iex CMAKE_INSTALL_PREFIX=D:/app/pangolin/build/install 编译过程中才下载且配置后也会调用其中信息,所以编译完成后重新将D:\app\pangolin\build\external加入build.zip 由于只编译Release版所以编译后打开修改D:\~\PangolinConfig.cmake中的其它依赖与libjpg依赖一样(即全配为release) (2)ubuntu编译 |
6.编译安装包
6.1fbow
(1)win编译 打开CMakeLists添加:set(BOOST_ROOT D:/app/boost) set(OpenCV_DIR D:/app/opencv/build/install) USE_CONTRIB=ON USE_OWN_EIGEN=ON CMAKE_INSTALL_PREFIX=D:/app/fbow/build/install (2)ubuntu编译 |
7.配置信息
7.1环境变量
D:\app\python;D:\app\python\Scripts D:\app\doxygen\bin D:\app\hdf5\bin D:\app\openni2\Redist D:\app\tbb\bin\intel64\vc14 D:\app\qt\5.6\msvc2015_64\bin D:\app\boost\lib64-msvc-14.0 D:\app\suitesparse\lapack_windows\x64 D:\app\opencv\build\install\x64\vc14\bin D:\app\vtk\build\install\bin D:\app\pcl\build\install\bin D:\app\flann\build\install\bin D:\app\qhull\build\install\bin D:\app\g2o\build\install\bin D:\app\octomap\build\install\bin D:\app\gtsam\build\install\bin D:\app\pangolin\build\install\bin C:\Program Files\Git\cmd C:\Program Files\CMake\bin C:\Windows\system32 C:\Windows\System32\Wbem C:\Windows\System32\WindowsPowerShell\v1.0 C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit C:\Program Files\Microsoft SQL Server\120\Tools\Binn C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp |
/etc/environment:系统启动时加载 /etc/profile:每个用户首次登录时加载 /etc/bash.bashrc:每个用户每次打开shell时加载 ~/.profile:对应用户首次登录时加载 ~/.bashrc:对应用户每次打开shell时加载 立即生效:source /etc/bash.bashrc 或source ~/.bashrc |
CMakeLists.txt
###Basic####################################################################
cmake_minimum_required(VERSION 2.8)
project(Aro CXX)
add_definitions(-DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS)
add_compile_options(-std=c11 -std=c++11 -fpermissive)
set(CMAKE_BUILD_TYPE DEBUG)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_SUPPRESS_REGENERATION TRUE)#不生成ZERO_CHECK工程
###0.0Self#############################################################
include_directories(${CMAKE_SOURCE_DIR}/include)
###0.1Boost#############################################################
set(BOOST_ROOT D:/app/boost)
find_package(Boost COMPONENTS serialization system filesystem thread program_options date_time timer chrono iostreams)
include_directories(${Boost_INCLUDE_DIRS})
message("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message("Boost_LIBRARIES: ${Boost_LIBRARIES}")
###1.1SuiteSparse#######################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/suitesparse/build/install/lib/cmake/suitesparse-4.5.0)
set(SuiteSparse_USE_LAPACK_BLAS ON)
find_package(SuiteSparse REQUIRED)
include_directories(${SuiteSparse_INCLUDE_DIRS})
message("SuiteSparse_INCLUDE_DIRS: ${SuiteSparse_INCLUDE_DIRS}")
message("SuiteSparse_LIBRARIES: ${SuiteSparse_LIBRARIES}")
###1.2Eigen##############################################################
include_directories(D:/app/eigen)
include_directories(D:/app/sophus)
message("Eigen is included directly")
message("Sophus is included directly")
###1.3Ceres&GFlags&GLog##################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/ceres/build/install/CMake)
list(APPEND CMAKE_PREFIX_PATH D:/app/glog/build/install/lib/cmake/glog)
list(APPEND CMAKE_PREFIX_PATH D:/app/gflags/build/install/lib/cmake/gflags)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
message("CERES_INCLUDE_DIRS: ${CERES_INCLUDE_DIRS}")
message("CERES_LIBRARIES: ${CERES_LIBRARIES}")
###2.1OpenCV##############################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/opencv/build/install)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
message("OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}")
message("OpenCV_LIBS: ${OpenCV_LIBS}")
###3.1PCL#################################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/pcl/build/install)
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
message("PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
message("PCL_LIBRARIES: ${PCL_LIBRARIES}")
###4.1G2O#################################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/g2o/build/install)
find_package(G2O REQUIRED)
include_directories(${G2O_INCLUDE_DIR})
message("G2O_INCLUDE_DIR: ${G2O_INCLUDE_DIR}")
message("G2O_LIBS: ${G2O_LIBS}")
###4.2Octomap#############################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/octomap/build/install/share/octomap)
list(APPEND CMAKE_PREFIX_PATH D:/app/octomap/build/install/share/dynamicEDT3D)
find_package(Octomap REQUIRED)
find_package(Dynamicedt3d REQUIRED)
include_directories(${OCTOMAP_INCLUDE_DIRS})
message("OCTOMAP_INCLUDE_DIRS: ${OCTOMAP_INCLUDE_DIRS}")
message("OCTOMAP_LIBRARIES: ${OCTOMAP_LIBRARIES}")
message("DYNAMICEDT3D_INCLUDE_DIRS: ${DYNAMICEDT3D_INCLUDE_DIRS}")
message("DYNAMICEDT3D_LIBRARIES: ${DYNAMICEDT3D_LIBRARIES}")
####4.3Gtsam################################################################
#list(APPEND CMAKE_PREFIX_PATH D:/app/gstam/build/install/CMake)
#find_package(Gtsam REQUIRED)
#include_directories(${GTSAM_INCLUDE_DIR})
#message("GTSAM_INCLUDE_DIR: ${GTSAM_INCLUDE_DIR}")
####4.4Pangolin#############################################################
list(APPEND CMAKE_PREFIX_PATH D:/app/pangolin/build/install/lib/cmake/Pangolin)
find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS} )
message("Pangolin_INCLUDE_DIRS: ${Pangolin_INCLUDE_DIRS}")
message("Pangolin_LIBRARIES: ${Pangolin_LIBRARIES}")
###CUDA###################################################################
#find_package(CUDA REQUIRED)
#include_directories(${CUDA_INCLUDE_DIRS})
#link_directories(${CUDA_LIBRARY_DIRS})
#set(CUDA_LIBS ${CUDA_CUDA_LIBRARY} ${CUDA_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cudart_static_LIBRARY} ${CUDA_cudadevrt_LIBRARY} ${CUDA_cupti_LIBRARY} ${CUDA_curand_LIBRARY} ${CUDA_cusolver_LIBRARY} ${CUDA_cusparse_LIBRARY} ${CUDA_npp_LIBRARY} ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
#message ("CUDA_INCLUDE_DIRS: ${CUDA_INCLUDE_DIRS}")
#message ("CUDA_LIBS: ${CUDA_LIBS}")#没有CUDA_LIBRARY_DIRS
###ZED######################################################################
#find_package(ZED REQUIRED CONFIG)
#include_directories(${ZED_INCLUDE_DIRS})
#link_directories(${ZED_LIBRARY_DIRS})
#message("ZED_INCLUDE_DIRS: ${ZED_INCLUDE_DIRS}")
#message("ZED_LIBRARY_DIRS: ${ZED_LIBRARY_DIRS}")
#message("ZED_LIBS: ${ZED_LIBS}")
###files######################################################################
file(GLOB cmkdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/*)
file(GLOB datdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/data/*)
file(GLOB incdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/*)
file(GLOB incbase LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/base/*)
file(GLOB inccalib LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/calib/*)
file(GLOB incsalient LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/salient/*)
file(GLOB incstereo LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/stereo/*)
file(GLOB incvslam LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/include/vslam/*)
file(GLOB srcdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/source/*)
source_group("data" FILES ${datdir})
source_group("include" FILES ${incdir})
source_group("include\\base" FILES ${incbase})
source_group("include\\calib" FILES ${inccalib})
source_group("include\\salient" FILES ${incsalient})
source_group("include\\stereo" FILES ${incstereo})
source_group("include\\vslam" FILES ${incvslam})
source_group("include\\vslam" FILES ${incvslam})
source_group("source" FILES ${srcdir})
file(GLOB windir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/window/*)
file(GLOB resdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/window/res/*)
file(GLOB subdir LIST_DIRECTORIES false ${CMAKE_SOURCE_DIR}/window/sub/*)
source_group("window" FILES ${windir})
source_group("window\\res" FILES ${resdir})
source_group("window\\sub" FILES ${subdir})
###exes###################################################################
add_executable(${PROJECT_NAME}
${cmkdir}
${datdir}
${incdir} ${incbase} ${inccalib} ${incsalient} ${incstereo} ${incvslam}
${srcdir}
${windir} ${resdir} ${subdir}
)
###libs####################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${PROJECT_NAME}
${Boost_LIBRARIES}
${SuiteSparse_LIBRARIES}
#NO Eigen
#NO Sophus
${CERES_LIBRARIES}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${G2O_LIBS}
${OCTOMAP_LIBRARIES} ${DYNAMICEDT3D_LIBRARIES}
${Pangolin_LIBRARIES}
#${CUDA_LIBS}
#${ZED_LIBS}
)