ubantu18.0.4安装colmap和报错解决

colmap是啥?能干啥?怎么用?那就需要百度了。纯安装和纯解决报错。
(搬运官方安装教程:https://colmap.github.io/install.html)
本文示例,均在root权限下进行!

1 安装ubantu库依赖项:

sudo apt-get install \
    git \
    cmake \
    build-essential \
    libboost-program-options-dev \
    libboost-filesystem-dev \
    libboost-graph-dev \
    libboost-system-dev \
    libboost-test-dev \
    libeigen3-dev \
    libsuitesparse-dev \
    libfreeimage-dev \
    libmetis-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    qtbase5-dev \
    libqt5opengl5-dev \
    libcgal-dev

在Ubuntu 16.04/18.04下,CGAL的CMake配置脚本是坏的,你还必须安装CGAL Qt5包:

sudo apt-get install libcgal-qt5-dev

2 安装Ceres Solver:

sudo apt-get install libatlas-base-dev libsuitesparse-dev
# git clone https://ceres-solver.googlesource.com/ceres-solver  goole连接不上
git clone https://github.com/ceres-solver/ceres-solver.git 
cd ceres-solver
# git checkout $(git describe --tags) # Checkout the latest release
git checkout 2.1.0  # 我安装时最新版本会报错 切成2.1.0就可以了 
mkdir build
cd build
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
make -j
sudo make install

2.1 问题

cmake遇到warning:

CMake Warning at CMakeLists.txt:398 (find_package):
  By not providing "Findgflags.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "gflags", but
  CMake did not find one.

  Could not find a package configuration file provided by "gflags" (requested
  version 2.2.0) with any of the following names:

    gflagsConfig.cmake
    gflags-config.cmake

  Add the installation prefix of "gflags" to CMAKE_PREFIX_PATH or set
  "gflags_DIR" to a directory containing one of the above files.  If "gflags"
  provides a separate development package or SDK, be sure it has been
  installed.

重新安装gflags后(参考连接),cmake很丝滑。

3 配置和编译colmap

git clone https://github.com/colmap/colmap.git
cd colmap
git checkout dev
mkdir build
cd build
cmake ..
make -j
sudo make install

3.1 遇到问题

cmake 正常,make 时报错如下:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_filesystem.a(operations.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_filesystem.a(path.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(cmdline.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(options_description.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(parsers.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(variables_map.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(value_semantic.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(positional_options.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(convert.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(config_file.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_program_options.a(utf8_codecvt_facet.o): relocation R_X86_64_32S against symbol `_ZNK5boost15program_options6detail18utf8_codecvt_facet9do_lengthERK11__mbstate_tPKcS7_m' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
src/exe/CMakeFiles/colmap_exe.dir/build.make:272: recipe for target 'src/exe/colmap' failed
make[2]: *** [src/exe/colmap] Error 1
CMakeFiles/Makefile2:756: recipe for target 'src/exe/CMakeFiles/colmap_exe.dir/all' failed
make[1]: *** [src/exe/CMakeFiles/colmap_exe.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

好家伙, 这能行?盘它。解决方案:

# 1 在colmap目录下,在创建build目录前
vim CMakeLists.txt
# 2 在文件开头适当位置(看着顺眼的地方--打开文件你就知道在哪了), 添加一行内容:
set(CMAKE_EXE_LINKER_FLAGS " -no-pie")
# 3 保存后,重建build目录,重新按步骤cmake..和make -j, 还有sudo make install

报错参考方案:https://blog.csdn.net/hanyulongseucas/article/details/87715186

3.2 验证和运行

colmap -h  # 可显示相关信息
colmap gui  # 没有GUI就不用运行了

4 官方教程

https://colmap.github.io/tutorial.html

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值