pamalite
13th July 2010, 10:38
Hi,
I have been trying all day to get a very simple OpenCV based program to compile. I tried on a Mac with OpenCV installed from source, all work as expected and the program is able to load and process an image provided. However, I am having a ton of difficulties to even get it to compile on WindowsXP, let alone run it!
I have searched Google and this forum for all the possible resolutions, but they all failed. I tried using the reimp, dlltool and pexports tools to convert the pre-compiled DLLs and LIBs from OpenCV and tried to link it. The compiler will not compile at all, but keep spitting out 2 errors:
1. undefined reference to OpenCV's methods and functions; or
2. ld.exe cannot find the *.a file even it is there.
These were what I did:
1. undefined reference
a. I use the reimp tool to generate a *.def and *.a file from the supplied LIB files downloaded from OpenCV's website.
b. I updated the pro file with
INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"
win32:LIBS += "C:\OpenCV2.1-1\lib\libcv210.a" \
"C:\OpenCV2.1-1\lib\libcvaux210.a" \
"C:\OpenCV2.1-1\lib\libcxcore210.a" \
"C:\OpenCV2.1-1\lib\libhighgui210.a" \
The error I got:
debug/main.o: In function `main':
C:\cygwin\home\kwong13\opencv_test1/main.cpp:36: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\cygwin\home\kwong13\opencv_test1/main.cpp:51: undefined reference to `cv::imshow(std::string const&, cv::Mat const&)'
C:\cygwin\home\kwong13\opencv_test1/main.cpp:55: undefined reference to `cv::waitKey(int)'
debug/main.o:C:\cygwin\home\kwong13\opencv_test1/../../../../OpenCV2.1/include/opencv/cxmat.hpp:378: undefined reference to `cv::fastFree(void*)'
collect2: ld returned 1 exit status
I have also tried following the MinGW tutorial on how to convert VC++ LIBs to MinGW's *.a. To no avail.
2. ld.exe cannot find the library even the file is there
a. I changed the pro file to
INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"
win32:LIBS += -l"C:\OpenCV2.1-1\lib\libcv210.a" \
-l"C:\OpenCV2.1-1\lib\libcvaux210.a" \
-l"C:\OpenCV2.1-1\lib\libcxcore210.a" \
-l"C:\OpenCV2.1-1\lib\libhighgui210.a"
And I get the following error:
g++ -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\opencv_test1.exe debug/main.o -L"c:\Qt\2010.02.1\qt\lib" -lC:\OpenCV2.1-1\lib\libcv210.a -lC:\OpenCV2.1-1\lib\libcvaux210.a -lC:\OpenCV2.1-1\lib\libcxcore210.a -lC:\OpenCV2.1-1\lib\libhighgui210.a -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
mingw32-make: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\OpenCV2.1-1\lib\libcv210.a
collect2: ld returned 1 exit status
I have also tried with this entry in the pro file:
win32:LIBS += -L"C:/OpenCV2.1-1/lib" -lcv210 -lhighgui210 -lcxcore210
Same error.
Perhaps is there anyone had successfully got this working?
I did find one or two forum threads stating they got it working. However, they never share how they did it, and the entry date was quite old. Thus, I assume they have no intention of sharing their success.
Please, can someone, anyone, please help me! I am really stuck with this for the passed 8 hours. I do not want to compile OpenCV on WindowsXP as I am afraid it will break my another app that uses OpenCV through Java.
Please help!
I have been trying all day to get a very simple OpenCV based program to compile. I tried on a Mac with OpenCV installed from source, all work as expected and the program is able to load and process an image provided. However, I am having a ton of difficulties to even get it to compile on WindowsXP, let alone run it!
I have searched Google and this forum for all the possible resolutions, but they all failed. I tried using the reimp, dlltool and pexports tools to convert the pre-compiled DLLs and LIBs from OpenCV and tried to link it. The compiler will not compile at all, but keep spitting out 2 errors:
1. undefined reference to OpenCV's methods and functions; or
2. ld.exe cannot find the *.a file even it is there.
These were what I did:
1. undefined reference
a. I use the reimp tool to generate a *.def and *.a file from the supplied LIB files downloaded from OpenCV's website.
b. I updated the pro file with
INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"
win32:LIBS += "C:\OpenCV2.1-1\lib\libcv210.a" \
"C:\OpenCV2.1-1\lib\libcvaux210.a" \
"C:\OpenCV2.1-1\lib\libcxcore210.a" \
"C:\OpenCV2.1-1\lib\libhighgui210.a" \
The error I got:
debug/main.o: In function `main':
C:\cygwin\home\kwong13\opencv_test1/main.cpp:36: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\cygwin\home\kwong13\opencv_test1/main.cpp:51: undefined reference to `cv::imshow(std::string const&, cv::Mat const&)'
C:\cygwin\home\kwong13\opencv_test1/main.cpp:55: undefined reference to `cv::waitKey(int)'
debug/main.o:C:\cygwin\home\kwong13\opencv_test1/../../../../OpenCV2.1/include/opencv/cxmat.hpp:378: undefined reference to `cv::fastFree(void*)'
collect2: ld returned 1 exit status
I have also tried following the MinGW tutorial on how to convert VC++ LIBs to MinGW's *.a. To no avail.
2. ld.exe cannot find the library even the file is there
a. I changed the pro file to
INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"
win32:LIBS += -l"C:\OpenCV2.1-1\lib\libcv210.a" \
-l"C:\OpenCV2.1-1\lib\libcvaux210.a" \
-l"C:\OpenCV2.1-1\lib\libcxcore210.a" \
-l"C:\OpenCV2.1-1\lib\libhighgui210.a"
And I get the following error:
g++ -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\opencv_test1.exe debug/main.o -L"c:\Qt\2010.02.1\qt\lib" -lC:\OpenCV2.1-1\lib\libcv210.a -lC:\OpenCV2.1-1\lib\libcvaux210.a -lC:\OpenCV2.1-1\lib\libcxcore210.a -lC:\OpenCV2.1-1\lib\libhighgui210.a -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
mingw32-make: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\OpenCV2.1-1\lib\libcv210.a
collect2: ld returned 1 exit status
I have also tried with this entry in the pro file:
win32:LIBS += -L"C:/OpenCV2.1-1/lib" -lcv210 -lhighgui210 -lcxcore210
Same error.
Perhaps is there anyone had successfully got this working?
I did find one or two forum threads stating they got it working. However, they never share how they did it, and the entry date was quite old. Thus, I assume they have no intention of sharing their success.
Please, can someone, anyone, please help me! I am really stuck with this for the passed 8 hours. I do not want to compile OpenCV on WindowsXP as I am afraid it will break my another app that uses OpenCV through Java.
Please help!