写在前面:此次安装是在Ubuntu 16.04 平台安装,不仅需要配置opencv还需要配置annaconda,由于之前安装过,所以导致此次报错较多。
总结:为了避免潜在的Python 或其他冲突,应该先安装 opencv再配置 annaconda 环境,否则 会导致有annaconda环境里面的配置与其他安装的配置冲突,这种冲突一般很难发现,所以在此之前打开~ .bashrc文件注释有关annaconda的配置和有关Python的配置(只注释自己安装的,不要注释其系统配置的);
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
## 以下东西注释调
# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/mrzhao/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/home/mrzhao/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/mrzhao/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/home/mrzhao/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH
export PYTHONHOME=/home/mrzhao/anaconda3/envs/DPT
1. 问题一
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::~RE()':
ts_gtest.cpp:(.text._ZN7testing8internal2RED2Ev+0xf): undefined reference to `regfreeA'
ts_gtest.cpp:(.text._ZN7testing8internal2RED2Ev+0x18): undefined reference to `regfreeA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::FullMatch(char const*, testing::internal::RE const&)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE9FullMatchEPKcRKS1_+0x32): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::PartialMatch(char const*, testing::internal::RE const&)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE12PartialMatchEPKcRKS1_+0x32): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::DeathTestImpl::Passed(bool)':
ts_gtest.cpp:(.text._ZN7testing8internal13DeathTestImpl6PassedEb+0x457): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::Init(char const*)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE4InitEPKc+0x72): undefined reference to `regcompA'
ts_gtest.cpp:(.text._ZN7testing8internal2RE4InitEPKc+0x94): undefined reference to `regcompA'
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_perf_core.dir/build.make:551: recipe for target 'bin/opencv_perf_core' failed
make[2]: *** [bin/opencv_perf_core] Error 1
CMakeFiles/Makefile2:3102: recipe for target 'modules/core/CMakeFiles/opencv_perf_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
[ 63%] Linking CXX executable ../../bin/opencv_test_core
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::~RE()':
ts_gtest.cpp:(.text._ZN7testing8internal2RED2Ev+0xf): undefined reference to `regfreeA'
ts_gtest.cpp:(.text._ZN7testing8internal2RED2Ev+0x18): undefined reference to `regfreeA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::FullMatch(char const*, testing::internal::RE const&)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE9FullMatchEPKcRKS1_+0x32): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::PartialMatch(char const*, testing::internal::RE const&)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE12PartialMatchEPKcRKS1_+0x32): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::DeathTestImpl::Passed(bool)':
ts_gtest.cpp:(.text._ZN7testing8internal13DeathTestImpl6PassedEb+0x457): undefined reference to `regexecA'
../../lib/libopencv_ts.a(ts_gtest.cpp.o): In function `testing::internal::RE::Init(char const*)':
ts_gtest.cpp:(.text._ZN7testing8internal2RE4InitEPKc+0x72): undefined reference to `regcompA'
ts_gtest.cpp:(.text._ZN7testing8internal2RE4InitEPKc+0x94): undefined reference to `regcompA'
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_test_core.dir/build.make:567: recipe for target 'bin/opencv_test_core' failed
make[2]: *** [bin/opencv_test_core] Error 1
CMakeFiles/Makefile2:3070: recipe for target 'modules/core/CMakeFiles/opencv_test_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_test_core.dir/all] Error 2
Makefile:165: recipe for target 'all' failed
2. 解决方法
Finally!!!
This undefined bug is because boost and linux system have the same regex.h file. And renaming this file of boost temporally can fix this. ref: https://groups.google.com/forum/#!searchin/caffe-users/regex.h/caffe-users/zTfFsRnNl9c/ckD-bar6BAAJ
So at the end I use my boost 1.59 and opencv2.4.12. and make the right opencv path for denseflow. this bug is fixed.
//这是由于boost 库和linux system 库有相同的regex.h,删除boost库,需要时再安装;
3.问题二
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetFieldDefaulted@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfDirectories@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadRGBAImage@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadTile@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFfree@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFGetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFTileSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `_TIFFmalloc@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFSetDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFReadScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFNumberOfTiles@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.2.so.6.2: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
modules/viz/CMakeFiles/opencv_test_viz.dir/build.make:184: recipe for target 'bin/opencv_test_viz' failed
make[2]: *** [bin/opencv_test_viz] Error 1
CMakeFiles/Makefile2:4984: recipe for target 'modules/viz/CMakeFiles/opencv_test_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_test_viz.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs...
/usr/bin/ld: warning: libopencv_core.so.2.4, needed by //usr/lib/x86_64-linux-gnu/libavfilter-ffmpeg.so.5, may conflict with libopencv_core.so.3.1
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFWriteEncodedStrip@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFGetField@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFNumberOfStrips@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFReadEncodedTile@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFReadRGBATile@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFClose@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFRGBAImageOK@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFOpen@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFReadEncodedStrip@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFSetField@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
/usr/local/lib/libopencv_imgcodecs.so.3.1.0: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
CMakeFiles/rgbd_tum.dir/build.make:171: recipe for target '../Examples/RGB-D/rgbd_tum' failed
make[2]: *** [../Examples/RGB-D/rgbd_tum] Error 1
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/rgbd_tum.dir/all' failed
make[1]: *** [CMakeFiles/rgbd_tum.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
4.解决方式
Custom build environments are not tested and probably not supported.
TIFF may depend on JPEG codec. You have these libs in different “locations”.,
//在不同位置,安装了多个版本tiff5–>删除多余的tiff5,查看 .bashrc有没有符合开始写的内容;
ps: 安装tiff5
sudo apt-get install libtiff5-dev
总结: 出现问题用Google浏览器搜索,解决问题 的效率比较高;
这篇博客主要记录了在Ubuntu16.04上安装Opencv时遇到的问题,由于之前已经安装了Anaconda,导致编译OpenCV时出现链接错误。问题在于Opencv的编译过程中,遇到了与Anaconda环境中的库冲突,特别是与Boost和TIFF库相关的链接错误。解决方案包括先卸载或临时移除冲突的库,如Boost的regex.h文件,以及处理不同版本的TIFF库的依赖问题。通过修改.bashrc文件,注释掉与Anaconda相关的路径和配置,可以避免这些冲突。此外,还提到了安装和管理库时应避免不同位置的多版本库共存,以减少类似问题的发生。
2205

被折叠的 条评论
为什么被折叠?



