我正在尝试使用MinGW(gcc / g++ 4.7.2),Windows 7,Eclipse CDT(Kepler)编译使用asmlibrary(由Yao Wei编写)的代码,但没有成功。我可以使用MVSC编译相同的库,Windows端口(asmlibrary.dll),并且作者还发布了应该可以与gcc一起使用的三个文件(cygasmlibrary-4.dll,libasmlibrary.a,libasmlibrary.dll.a)。
当我尝试编译使用asmlibrary的代码时,出现此错误:

13:06:05 **** Rebuild of configuration Release for project AsmLibrarySDK_FIT ****
Info: Internal Builder is used for build
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o demo_fit.o "..\\demo_fit.cpp"
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o video_camera.o "..\\video_camera.cpp"
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o vjfacedetect.o "..\\vjfacedetect.cpp"
..\vjfacedetect.cpp: In function ‘bool detect_all_faces(asm_shape**, int&, const IplImage*)’:
..\vjfacedetect.cpp:85:11: warning: variable ‘pt1’ set but not used [-Wunused-but-set-variable]
..\vjfacedetect.cpp:85:16: warning: variable ‘pt2’ set but not used [-Wunused-but-set-variable]
g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o -lopencv_calib3d246 -lopencv_contrib246 -lopencv_core246 -lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246 -lopencv_nonfree246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246 -lopencv_video246 -lopencv_videostab246 -lasmlibrary
demo_fit.o:demo_fit.cpp:(.text.startup+0x4c9): undefined reference to `_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x638): undefined reference to `_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x21c): undefined reference to `_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x286): undefined reference to `_imp___ZN10asmfitting8Fitting2EP9asm_shapeiPK9_IplImagei'
demo_fit.o:demo_fit.cpp:(.text.startup+0x442): undefined reference to `_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x58c): undefined reference to `_imp__InitShapeFromDetBox'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: demo_fit.o: bad reloc address 0x0 in section `.ctors'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

我问作者这个问题,他回答如下:



我不明白的
即使我从命令行尝试,g++也不会接受:
C:\Users\Nenad\eclipseCDT\opencv2cookbook\AsmLibrarySDK_FIT\Debug>g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o -l
opencv_calib3d246 -lopencv_contrib246 -lopencv_core246 -lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246 -lopencv_nonfr
ee246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246 -lopencv_video246 -lopencv_videostab246 libasmlibrary.a

(错误与帖子顶部相同)
如果我尝试放-libasmlibrary.a(当然是),则会得到:
    c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -llibasmlibrary.a

libasmlibrary gives me g++: error: libasmlibrary: No such file or directory
and so on...

据我所知,链接此库的唯一正确方法是使用-lasmlibrary,但随后会产生顶部提到的错误。

顺便说一句,即使我根本不包含该库,也还是会出现此错误。

然后我再次问作者,他回答我:



即使我这样做(或者至少我认为我理解他),它也会产生相同的结果。当然,我什至将(cygasmlibrary-4.dll,libasmlibrary.a,libasmlibrary.dll.a)复制到调试目录中。
g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o libasmlibrary.a -lopencv_calib3d246 -lopencv_contrib246 -lopencv_core246 -lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246 -lopencv_nonfree246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246 -lopencv_video246 -lopencv_videostab246

Eclipse本身的设置如下:



可能这是一个新手问题,但我对此一无所知。
我应该怎么做才能使其编译?

最佳答案

据我所知,图书馆很难使用,并且不是开源的。您看过这个项目(请参阅第6章)https://github.com/MasteringOpenCV/code吗?我认为这样做会更好。还要看看http://www.visionopen.com/downloads/open-source-software/vosm/。这些项目是开源的,并且比asm库具有更多的描述。

08-16 10:05