../

openCV on FCC

Fujitsu製コンパイラFCCでopenCV-1.1.0をコンパイルしてみる.

まだうまくいっていませんw

GCC/G++ではうまくいくのだが,FCCでは案の定,いろいろエラーが出るし,解決方法もまったく情報がない.付け焼き刃的対処法とともに述べる.

免責

当方,Linuxはかじった程度です.本稿に記載の内容によって読者に生じるいかなる障害も,記者は関知しません.自己責任で行ってください.

目次

環境

  • openCV-1.1.0
    • 2008.9.9現在,まだ開発途上.CVSから落としてくる.ソースコードにバグがあるのでそれはこちら[../opencv-1.1.0OnFedora6]で対処
  • FCC
    • FCC: Fujitsu C++ Compiler Driver Version 3.0 (Feb 15 2008 10:29:49)
  • linux kernel, architecture
    • 2.6.9-67.ELlargesmp x86_64

error

otherlibs/highgui/window-gtk.cpp

  • 状況
    • fccのプリプロセッサは可変引数に対応していないのでエラーが出る.
  • 対処
    • 環境変数CXXFLAGSに--variadic_macrosを追加すればok

エラー文

source='../../../otherlibs/highgui/window_gtk.cpp' object='window_gtk.lo' libtool=yes \ DEPDIR=.deps depmode=none /bin/sh ../../../autotools/depcomp \ /bin/sh ../../libtool --tag=CXX --mode=compile FCC -DHAVE_CONFIG_H -I. -I../../../otherlibs/highgui -I../.. -I. -I../../../cxcore/include -I../../../cv/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DNDEBUG -O3 -g -c -o window_gtk.lo ../../../otherlibs/highgui/window_gtk.cpp

FCC -DHAVE_CONFIG_H -I. -I../../../otherlibs/highgui -I../.. -I. -I../../../cxcore/include -I../../../cv/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DNDEBUG -O3 -g -c ../../../otherlibs/highgui/window_gtk.cpp  -DPIC -o .libs/window_gtk.o

FCC: warning: -p option is ignored. FCC: warning: -g option is specified, -O option is ignored. "/usr/include/glib-2.0/glib/gmessages.h", line 114: error: expected an identifier

 #define g_error(...)    g_log (G_LOG_DOMAIN,         \
                 ^

"/usr/include/glib-2.0/glib/gmessages.h", line 117: error: expected an identifier

 #define g_message(...)  g_log (G_LOG_DOMAIN,         \
                   ^

"/usr/include/glib-2.0/glib/gmessages.h", line 120: error: expected an identifier

 #define g_critical(...) g_log (G_LOG_DOMAIN,         \
                    ^

"/usr/include/glib-2.0/glib/gmessages.h", line 123: error: expected an identifier

 #define g_warning(...)  g_log (G_LOG_DOMAIN,         \
                   ^

"../../../otherlibs/highgui/window_gtk.cpp", line 154: warning: variable "image_widget" was set but never used

   CvImageWidget *image_widget;
                  ^

"../../../otherlibs/highgui/window_gtk.cpp", line 536: warning: statement is unreachable

 	return NULL;
 	^

4 errors detected in the compilation of "../../../otherlibs/highgui/window_gtk.cpp".

cv/src/_cvkdtree.hpp

  • 状況
    • STLの<algorithm>内のヒープ関数,push_heap(), pop_heap()がundefinedと怒られる
  • 対処
    • スコープ解決演算子をつける
      std::push_heap();
      std::pop_heap();

cvaux/include/cvvidsurv.hpp

  • 状況
    • GCCかBORLANDコンパイラでないと通らない箇所があって,FCCでは
      #error notimplemented
      的な返答がくる.
  • 対処
    • 該当個所のマクロをとっぱらうw

virtualなデストラクタを持ったクラスがうまく継承できない

  • 状況
    • openCVのコンパイル終了後,CvSVMから派生クラスをつくると,リンク時に
      ld: undefined 'type info for CvSVM'
      のように怒られる.CvKNearest, CvStatModel?などもそう.
  • 対処
    • 共有ライブラリにtype_infoが抜けているらしい.ライブラリに実行時型情報(RunTimeTypeInfo?)を持たせるため,openCVのconfigure時に,
      setenv CXXFLAGS "-frtti"; ./configure ....
      とすれば解決した.

lib**.soが生成されない

  • 共有ライブラリはダメなのか・・・???????
  • しゃぁないので, configureに--enable-static, --disable-shareオプションを付けて解決

マニュアルを参照して,有用そうなオプションを開拓.

-KOMP -Kparallel,reduction 

以上の処理をへて,最終的なコンフィグコマンドはこちら

setenv CXX FCC
setenv CXXFLAGS "-frtti --variadic_macros --alternative_tokens  -DUSE_C_ALLOCA -Dalloca=C_alloca '-D_EXTERN_INLINE=static __inline'"
../configure  --disable-apps --enable-static --disable-shared  --without-python --prefix=/home/t/tXXXXX/opencv-1.1.0.fccFCC.extern.alloca
#ここで各makefileをチェックし, -O3 とか -fno-rtti とかのオプションを外す...
make 
make install

とりあえずこれでOK

うちの研究室で使っているライブラリ用のコンフィグ

メモリのアロケーション

opencv-1.1.0.fccFCC.extern.C_alloca/include/opencv/cxmisc.h

インストールしたopencvのヘッダを書き換え.

@122行目 +#include <alloca.h>
@134行目 -#elif 
@134行目 +#elif 0

これでopencvpatchedのコンパイルも通るはず.

for GTK user

  • gtkのライブラリおよびヘッダは自前でインクルード・リンクせねばならない.そこでGTKを必要とするプログラムのMakefileに次の行を追加.このときgtherad-initがないとか怒られるので-lgthread-2.0もまとめてリンクしてしまうw
    • ヘッダ:`pkg-config --cflags gtk+-2.0 gdk-pixbuf-2.0`
    • ライブラリ:`pkg-config --libs gtk+-2.0 gdk-pixbuf-2.0` -lgthread-2.0

memo

  • KOMPオプションをつけてコンパイルすると
    #pragma omp parallel for num_thread(thread_count)
    の箇所で怒られた.戦う気力はなかったので,コンパイルオプションを削除.
  • 極個人的メモ
    • SKLのコンパイル時には--alternative_tokensオプションを付ける.
    • configure終了後,全makefileの--fno-rttiと-O3のオプションを除去
  • エラーが出ると思ったらIPP(intel performance primitive)を使ったオブジェクトファイルをリンクできないとか.はぁ?

気になるサイト

  • http://www.mysql.gr.jp/Manual/mysql-3.23.38/manual.ja_Installing.html
    • MySQLをfcc/FCCでコンパイルする際の情報.試してみる価値あり.最終的に下のコマンドでコンパイルしている.
      CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE -DCONST=const -DNO_STRTOLL_PROTO" CXX=FCC CXXFLAGS="-O -K fast -K lib  -K omitfp -K preex --no_exceptions --no_rtti -D_GNU_SOURCE -DCONST=const -Dalloca=__builtin_alloca -DNO_STRTOLL_PROTO '-D_EXTERN_INLINE=static __inline'" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-shared --with-low-memory

comment

#comment_kcaptcha


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-11-08 (日) 20:06:00 (5303d)