重新安装opencv,踩坑。

写在前面:此次安装是在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浏览器搜索,解决问题 的效率比较高;

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装opencv的过程可能会遇到一些问题,下面是一些在Ubuntu 18.04上安装opencv时可能会遇到的常见问题及解决方法的指南。 1. 缺少依赖项:在安装opencv之前,确保已经安装了必需的依赖项。这包括cmake、build-essential、libgtk2.0-dev、pkg-config和python3-dev等。可以使用以下命令安装它们: ``` sudo apt-get install cmake build-essential libgtk2.0-dev pkg-config python3-dev ``` 2. 版本冲突:如果你的系统中已经安装了ROS-melodic,并且ROS-melodic中已经自带了opencv-3.2.0版本,你可能需要手动编译和安装opencv-3.2.0来覆盖ROS-melodic中的版本。首先下载opencv-3.2.0和opencv_contrib-3.2.0的源代码,并切换到opencv-3.2.0/build目录。然后使用make和make install命令进行编译和安装: ``` cd ~/Downloads/opencv_install/opencv-3.2.0/build/ make sudo make install ``` 3. 其他问题:在安装过程中可能会遇到其他问题,例如编译错误或链接错误。这些问题通常可以通过在安装过程中查找错误消息并搜索解决方案来解决。可以查看相关的安装教程、论坛或社区提供的文档以获取更多帮助。 总结起来,安装opencv的过程可能会因为缺少依赖项或版本冲突而出现问题。确保安装了必需的依赖项,并根据需要手动编译和安装适当的版本来解决版本冲突。在遇到其他问题时,可以查找相关的资源以获取更多帮助和解决方案。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Ubuntu18.04安装opencv 3.2.0的解决方法](https://download.csdn.net/download/weixin_38637983/12842575)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [在ubuntu18.04中安装opencv_contrib-3.2.0采教程](https://blog.csdn.net/hiram_zhang/article/details/103467737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值