歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 12.04中OpenCV靜態編譯

Ubuntu 12.04中OpenCV靜態編譯

日期:2017/2/28 15:32:15   编辑:Linux教程

1.Ubuntu 12.04中沒有了新立德,忍受不了軟件中心的慢,所以安裝了新立德

apt-get install synaptic

2.安裝gcc等C/C++編程相關工具

sudo apt-get install build-essential

3.安裝gtk+(opencv的界面顯示就靠它了)

安裝GTK環境只要安裝一個libgtk2.0-dev就可以了,而安裝gnome開發環境的話,需要裝gnome-core-devel,它包含GTK開發包。

sudo apt-get install gnome-core-devel(有點慢,需要下載,看網速)

pkg-config --modversion gtk+ (查看1.2.x版本)

pkg-config --modversion gtk+-2.0 (查看 2.x 版本)

pkg-config --version (查看pkg-config的版本)

pkg-config --list-all |grep gtk (查看是否安裝了gtk)

4.使用synaptic安裝cmake-qt版本

有界面的cmake配置opencv編譯選項方便些

5.安裝wxWidgets(codeblocks IDE需要到)V2.8

由於codeblocks是用wxWidgets開發的,所以wxWidgets需要先安裝.以最小化體積為編譯目的,shared,unicode版本,庫文件編譯為一個文件,不支持2.8,去掉debug信息,最終配置命令如下(./configure --help可查看參數信息):

./configure --enable-unicode --enable-shared--enable-monolithic --disable-compat28 --disable-debug_flag

make(需要一定時間)

make install

ldconfig(需要把/usr/local/lib加到/etc/ld.so.conf最後一行中,再執行ldconfig)

編譯後的文件放在/usr/local/bin和/usr/local/lib目錄中,可通過—prefix改變路徑.

由於Codeblocks暫時只支持2.8,所以卸載2.9的:make uninstall.重新安裝2.8

./configure --enable-unicode --enable-shared--enable-monolithic --disable-compat26 --disable-debug_flag

make(需要一定時間)

make install

6.安裝CodeBlocks(Ver10.05)

Codeblocks最新版本10.05(截至2012-5-12)只能使用wxWidgets2.8,不兼容2.9.使用2.9會出現以下錯誤:editarrayorderdlg.h:20:error: default argument for parameter of type 'const wxArrayString&' hastype 'long int'. 且wxWidgets需編譯成單一文件.源代碼下的BUILD文件裡面有編譯說明.直接順序執行以下三條命令就行.

./configure --with-contrib-plugins=all

make

make install

安裝完成後,打開它只發現它在任務欄中閃一會兒就消失了,出不了界面.在終端得運行提示:codeblocks:error while loading shared libraries: libcodeblocks.so.0: cannot open sharedobject file: No such file or directory

解決辦法為:In that case make sure the library path where the Code::Blocks librarieswhere installed into is "known" to the system. For example: On Ubuntuusing a default build process on a clean system will install the Code::Blocksexecutables to /use/local/bin and the libraries to /usr/local/lib. The latteris usually not known to a "clean" Ubuntu system. To add it to thesearch path for libraries do the following (as root / using sudo respectively):Add the following line to the file /etc/ld.so.conf:

/usr/local/lib

...and run:

ldconfig

That's it - Code::Blocks should now work just fine asall libraries are being found.

wxSmith用不了,打開CB提示:

/usr/local/lib/codeblocks/plugins/libwxSmithAui.so:not loaded (missing symbols?)

/usr/local/lib/codeblocks/plugins/libwxsmithcontribitems.so:not loaded (missing symbols?)

/usr/local/lib/codeblocks/plugins/libwxsmith.so: notloaded (missing symbols?)

運行 sudo ldconfig就行

Copyright © Linux教程網 All Rights Reserved