Opencv Linux


1. Get sourcecode download OpenCV_xx.tar
   tar xvf ~/Downloads/OpenCV-2.3.1a.tar.bz2
   cd  OpenCV-2.3.1
 # sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev cmake libswscale-dev libjasper-dev
 #./configureはopencv 2.1以降は採用されず、cmakeを使用してconfigを構成できます.
 # svn co https://code.ros.org/svn/opencv/trunk 
2. configure opencv Cmake&&GCC
For example, if you downloaded the project to ~/projects/opencv, you can do the following:
   cd ~/projects/opencv # the directory containing INSTALL, CMakeLists.txt etc.
   mkdir release
   cd release
   cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..

Note: ..前のレベルのディレクトリ3.compile using gcc  cd release  make install     notes:        3.1 download ffmpeg and build              svn co svn://svn.mplayerhq.hu//ffmpeg/trunk ffmpeg              ./configure --enable-shared --disable-yasm               make              sudo make install
Now you have to configure the library. First, open the opencv.conf file with the following code: sudo gedit /etc/ld.so.conf.d/opencv.conf
Add the following line at the end of the file(it may be an empty file, that is ok) and then save it: /usr/ local /lib
Run the following code to configure the library: sudo ldconfig
Now you have to open another file: sudo gedit /etc/ bash .bashrc
Add these two lines at the end of the file and save it: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/ local /lib/pkgconfig export PKG_CONFIG_PATH
4. Test example   g++ `pkg-config opencv --libs --cflags opencv` drawing.c -o drawing Note: 1. ``ここはセミコロンではなく、数字1キーの左の該当です.          2.   sudo apt-get install libgtk2.0-dev pkg-config build_all.sh #!/bin/sh if [ $# -gt 0 ] ; then         base=`basename $1 .c`         echo "compiling $base"        gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base else         for i in *.c; do             echo "compiling $i"            gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;         done         for i in *.cpp; do             echo "compiling $i"            g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;         done fi  

(原)error while loading shared libraries解決方法


2012年04月01日に執筆|分類:Opencv|7件のコメント
今日2回目のubuntuでopencvの開発環境を構成し、コンパイラ時にerror while loading shared libraries:libopencv_core.so.2.3:cannot open shared object file:No such file or directoryのエラー.
原因:このようなエラー表示が発生し、システムはxxxを知らない.soはどのディレクトリの下に置くか、このとき/etc/ldに置く.so.confにxxxを加える.soが存在するディレクトリ.
解決方法:/etc/ld.so.confに/usr/local/libという行を追加し、保存してから実行します:/sbin/ldconfig–v構成を更新すればいいです.
 :sudo vi /etc/ld.so.conf
 :/usr/local/lib 
 , , :sudo /sbin/ldconfig -v

これで、コンパイルできます!