编译OpenCv例程时错误解决办法

2013年8月5日 由 Creater 留言 »

1.在make时出现如下错误
In file included from _cxcore.h:60,
from cxalloc.cpp:42:
../../cxcore/include/cxmisc.h:133:6: error: #elif with no expression
make[3]: *** [cxalloc.lo] 错误 1
解决办法:
修改cxcore/include/cxmisc.h的133行的#elif为#else,保存退出。

 

 

2.使用如下的shell命令编译例程中的例子

g++ `pkg-config opencv --libs --cflags opencv` -lcv drawing.c -o drawing -L/usr/local/lib -I/usr/local/include/opencv

出现错误:
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘opencv’ found
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc’
to the PKG_CONFIG_PATH environment variable
No package ‘opencv’ found
/tmp/ccU02C6B.o: In function `main’:
drawing.c:(.text+0x119): undefined reference to `cvNamedWindow’
drawing.c:(.text+0x13d): undefined reference to `cvShowImage’
drawing.c:(.text+0x329): undefined reference to `cvShowImage’
drawing.c:(.text+0x335): undefined reference to `cvWaitKey’
drawing.c:(.text+0x4e8): undefined reference to `cvShowImage’
drawing.c:(.text+0x4f4): undefined reference to `cvWaitKey’
drawing.c:(.text+0x72c): undefined reference to `cvShowImage’
drawing.c:(.text+0x738): undefined reference to `cvWaitKey’
drawing.c:(.text+0xa52): undefined reference to `cvShowImage’
drawing.c:(.text+0xa5e): undefined reference to `cvWaitKey’
drawing.c:(.text+0xd41): undefined reference to `cvShowImage’
drawing.c:(.text+0xd4d): undefined reference to `cvWaitKey’
drawing.c:(.text+0xecc): undefined reference to `cvShowImage’
drawing.c:(.text+0xed8): undefined reference to `cvWaitKey’
drawing.c:(.text+0x1178): undefined reference to `cvShowImage’
drawing.c:(.text+0x1184): undefined reference to `cvWaitKey’
drawing.c:(.text+0x1375): undefined reference to `cvShowImage’
drawing.c:(.text+0x1381): undefined reference to `cvWaitKey’
drawing.c:(.text+0x13a3): undefined reference to `cvWaitKey’
drawing.c:(.text+0x13cb): undefined reference to `cvDestroyWindow’
collect2: ld 返回 1
由提示得到解决办法:
需要让pkg-config找到opencv.pc
所以执行下面的shell

cp opencv.pc  /usr/lib/pkgconfig/

广告位

发表评论

你必须 登陆 方可发表评论.