Sunday, 18 August 2013

asmlibrary with OpenCV and MinGW

asmlibrary with OpenCV and MinGW

I am trying to compile code which uses asmlibrary (by Yao Wei) with MinGW
(gcc/g++ 4.7.2), Windows 7, Eclipse CDT (Kepler) , without success. I can
compile same library, windows port (asmlibrary.dll) with MVSC, and author
also published three files (cygasmlibrary-4.dll, libasmlibrary.a,
libasmlibrary.dll.a) which supposedly should work with gcc. When I try to
comppile code which uses asmlibrary, I got this error:
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
I asked author about this and he replied to me as follows:
just link like libasmlibrary.a not -lasmlibrary
what I don't understand. Even if I try from command line, g++ won't accept:
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
(error is same as on top of post) if I try to put -libasmlibrary.a (the of
course) I got:
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...
As far as I know the only correct way to link this library would be to use
-lasmlibrary but then it produces the error mentioned at the top.
BTW, even if I don't include that library at all, I got this error anyway.
Then I asked author again, and he replied to me:
Code like this g++ a.c -o test libasmlibrary.a -lopencv_library
And even if I do that way (or at least I think I understood him) it yields
same result. Of course I even copied (cygasmlibrary-4.dll,
libasmlibrary.a, libasmlibrary.dll.a) into debug directory.
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
Settings in Eclipse itself are as follows:


Probably this is a newbie question, but I am totally stuck with this. What
should I do to make it compile?

No comments:

Post a Comment