私が取り組んでいるより大きなプロジェクトの一環として、CプログラムでOpenCVライブラリを使用する必要があります。Fedora1732ビットでyumを使用してOpenCVとopencv-develをインストールしました。プリプロセッサに、必要なヘッダーファイルとしてopencv/cv.hとopencv/highgui.hをインポートするように指示しました。
すでに述べたように、gccはCプロジェクト全体をコンパイルするために使用されます。ただし、リンカーに問題があるようです。
プロジェクト()をコンパイルしようとするとgcc opencv.c -o opencv
、次のようなエラーのリストが表示されます。
/tmp/ccLJWE0c.o: In function `cvRound': opencv.c:(.text+0x19):
undefined reference to `lrint' /tmp/ccLJWE0c.o: In function
`cvDecRefData': opencv.c:(.text+0xa5c): undefined reference to
`cvFree_' opencv.c:(.text+0xacd): undefined reference to `cvFree_'
/tmp/ccLJWE0c.o: In function `cvGetRow': opencv.c:(.text+0xbc3):
undefined reference to `cvGetRows' /tmp/ccLJWE0c.o: In function
`cvGetCol': opencv.c:(.text+0xbee): undefined reference to `cvGetCols'
/tmp/ccLJWE0c.o: In function `cvReleaseMatND': opencv.c:(.text+0xc01):
undefined reference to `cvReleaseMat' /tmp/ccLJWE0c.o: In function
`cvSubS': opencv.c:(.text+0xd21): undefined reference to `cvAddS'
/tmp/ccLJWE0c.o: In function `cvCloneSeq': opencv.c:(.text+0xd6f):
undefined reference to `cvSeqSlice' /tmp/ccLJWE0c.o: In function
`cvSetNew': opencv.c:(.text+0xdce): undefined reference to `cvSetAdd'
/tmp/ccLJWE0c.o: In function `cvGetSetElem': opencv.c:(.text+0xe61):
undefined reference to `cvGetSeqElem' /tmp/ccLJWE0c.o: In function
`cvEllipseBox': opencv.c:(.text+0xf61): undefined reference to
`cvEllipse' /tmp/ccLJWE0c.o: In function `cvFont':
opencv.c:(.text+0xfb1): undefined reference to `cvInitFont'
/tmp/ccLJWE0c.o: In function `cvReadIntByName':
opencv.c:(.text+0x103f): undefined reference to `cvGetFileNodeByName'
/tmp/ccLJWE0c.o: In function `cvReadRealByName':
opencv.c:(.text+0x10d0): undefined reference to `cvGetFileNodeByName'
/tmp/ccLJWE0c.o: In function `cvReadStringByName':
opencv.c:(.text+0x112a): undefined reference to `cvGetFileNodeByName'
/tmp/ccLJWE0c.o: In function `cvReadByName': opencv.c:(.text+0x115a):
undefined reference to `cvGetFileNodeByName' opencv.c:(.text+0x1170):
undefined reference to `cvRead' /tmp/ccLJWE0c.o: In function
`cvCreateSubdivDelaunay2D': opencv.c:(.text+0x11a3): undefined
reference to `cvCreateSubdiv2D' opencv.c:(.text+0x11cd): undefined
reference to `cvInitSubdivDelaunay2D' /tmp/ccLJWE0c.o: In function
`cvContourPerimeter': opencv.c:(.text+0x1307): undefined reference to
`cvArcLength' /tmp/ccLJWE0c.o: In function `cvCalcHist':
opencv.c:(.text+0x132f): undefined reference to `cvCalcArrHist'
/tmp/ccLJWE0c.o: In function `main': opencv.c:(.text+0x14cd):
undefined reference to `cvCreateImage' opencv.c:(.text+0x1510):
undefined reference to `cvGet2D' opencv.c:(.text+0x159e): undefined
reference to `cvSet2D' opencv.c:(.text+0x15df): undefined reference to
`cvSaveImage' collect2: error: ld returned 1 exit status
また、次を使用してプログラムをコンパイルすると、次のようになります。
gcc opencv.c -o opencv `pkg-config --libs --cflags opencv` -ldl
私はまだ得ます:
/usr/bin/ld: /tmp/ccMRviO3.o: undefined reference to symbol 'lrint@@GLIBC_2.1'
/usr/bin/ld: note: 'lrint@@GLIBC_2.1' is defined in DSO /lib/libm.so.6 so try adding it to the linker command line
/lib/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
私は解決策を見つけようとしていますが、問題を解決するものは何もないようです。OpenCVのドキュメントでは、必要なライブラリをインストールする別の方法について言及されていますが、私が従わなければならない手順を本当に理解していません。Fedoraは、コンパイルされてすぐに使用できるパッケージを開発していると思いました。とにかく、これが問題である場合、すべてを機能させる簡単な方法はありますか?
Visual Basicでコーディングして6年になりますが、大学教育の一環としてCを学び始めたばかりです。したがって、私はGCCの操作の経験があまりありません。:(できるだけ説明してください!:)
どんな助けでも大歓迎です!前もって感謝します!!!:D