If you've been following the Game Player project I've been blogging about you'll know I has some trouble getting the 64 bit libraries of OpenCV to link with my project and had to stick with the 32 bit ones. Here I'll go into more details about the problem and hopefully find a solution.
First a little bit of background information on my system:
- Windows 7 Home Premium 64 bit
- OpenCV 2.4.2 pre-compiled binaries
- Netbeans 7.0.1
- Java 1.6 (not sure of bitness)
- MinGW-32 C Compiler with gcc version 4.5.2
Really the Netbeans and Java version shouldn't matter as I am trying to compile C code and the fact I'm calling the compiler from within Netbeans should make no difference (however we will keep it in mind if no other fix works). Really, looking at this list, it looks like the problem is with the C compiler being 32 bit but if you check out the
Wikipedia page on MinGW you can see it says:
" MinGW was originally called mingw32; the numbers were dropped in order to avoid the
implication that it would be limited to 32-bit systems. "
So it should be fine. However I need to start somewhere and this is as good as anywhere. Although let me describe the problem I'm having before attempting any solutions.
This is my current settings, these work:
|
Nothing set for the C compiler. |
|
C++ compiler points to the build/include dir and has some arguments. |
|
Linker points to the 32 bit libraries (x86 folder). |
|
The libraries added from the above folder. |
I can't remember the exact impact of the arguments in the C++ compiler options but I believe they are used to make sure JNI can find the methods in the compiled binaries when it calls them from Java. I also have the path to the /bin folder (C:\OpenCV2.4.2\opencv\build\x86\mingw\bin) added to my Windows PATH variable.
So this works and compiles fine and can be called from Java with no issues as we see below:
|
32 bit successfully compiles. |
But when I change the libraries to point to the 64 bit ones I get the following error:
|
64 bit fails to compile. |
The compiler is complaining that it can no longer find the functions being called in my code. How annoying.
Maybe it's because I don't have the path to the 64 bit /bin directory (C:\OpenCV2.4.2\opencv\build\x64\mingw\bin) in my PATH variable, so I've added that and restarted. Nope, it's made no difference.
There is another way to set up the system though, instead of pointing to the /lib directory we can point straight to the /bin directory and add all the .dll files from there instead so lets try that for the 32 bit version to see if it works. If you try this as well take note that the .dll files might not appear in the file selector window without changing the file type to 'All files':
|
Libraries changed to directly use the 32 bit binaries from the /bin folder. |
|
32 bit successfully compiles using the /bin folder. |
There is a reason behind using the files in the /lib folder rather than those in the /bin folder but I can't remember it and I can't find the page that explained it so lets move on and try using the 64 bit binaries directly:
|
Libraries changed to use 64 bit binaries directly from /bin folder. |
|
64 bit fails to compile with a new error. |
Here we are with a new error. This time the compiler is complaining that the 'File format is not recognized.' Interesting. My theory behind the difference in errors between linking to the binaries directly as opposed to going through the lib files is that the lib method adds an extra level of abstraction which is checking for the methods in the binaries which it can't find because it can't understand the file format. This would explain why when we link directly we get the file format error and when we link indirectly we get the cannot find methods errors. That's my theory anyway.
You can also force the compiler into using 64 bit architecture but that makes no difference so I won't bother going into that.
I guess there is no choice but to go into the fun and games of replacing the compiler. I'll do that another time though, I'm a bit tired now and I can only take things not working for me for so long!
No comments:
Post a Comment