I have built a static opencv library based on this post, and after that I want to invoke the static opencv library for my application. However, it seems that the application program cannot link the static opencv library, and it gives me the following warnings:
ld: warning: ignoring file /usr/local/lib/libopencv_core.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libopencv_core.a
ld: warning: ignoring file /usr/local/lib/libopencv_highgui.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libopencv_highgui.a
ld: warning: ignoring file /usr/local/lib/libopencv_imgproc.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libopencv_imgproc.a
ld: warning: ignoring file /usr/local/lib/liblibjasper.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/liblibjasper.a
ld: warning: ignoring file /usr/local/lib/liblibjpeg.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/liblibjpeg.a
ld: warning: ignoring file /usr/local/lib/liblibpng.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/liblibpng.a
ld: warning: ignoring file /usr/local/lib/liblibtiff.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/liblibtiff.a
ld: warning: ignoring file /usr/local/lib/libzlib.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libzlib.a
ld: warning: ignoring file /usr/local/lib/libIlmImf.a, file was built for archive which is not the architecture being linked (i386): /usr/local/lib/libIlmImf.a
It seems to me that the application program is trying to invoke the dynamic opencv library, and a simple application program that just invokes cv::Mat
test will give me the following errors:
Undefined symbols for architecture i386:
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in main.o
"cv::fastFree(void*)", referenced from:
cv::Mat::~Mat() in main.o
EDIT: As the answers suggest it is not the link problem rather it is a problem of linking libraries built for different architecture. Besides that, two other important things you should pay attention to when building and using a static OpenCV library are:
Make sure it builds Active Architecture Only (yes).
Also you should link
framework Cocoa;general;-framework QTKit;general;-framework QuartzCore;general;-framework AppKit;
that opencv_highgui.a uses.