My end goal is to have a portable Opencv program that I can easily install and use on other Windows computers. I have successfully written the program using codeblocks and Mingw.
Currently I have a functioning program that uses OpenCV's dynamic linked libraries. But when I move the executable anywhere, it can't find the dlls.
I have attempted to use static libraries so that I don't have to install Opencv on the computers that will be running the program, and everything can run from the executable. The following are the steps I took.
- Compile Static Libraries using CMAKE, Opencv source, and Mingw64 using the BUILD_SHARED_LIB = OFF. This gives me a series libopencv_xxxxx.a (I saw a similar problem using opencv and qt where the compiler flag was adding 'lib' to the front of these names causing an error - not the case in codeblocks.)
- Set the Codeblocks build options as follows:
When I build this, I get a series of "undefined reference to 'xxxxx'" errors.
e.g.
Build Messages
C:\opencv\build\x64\mingw (static)\staticlib\libopencv_core2410.a(persistence.cpp.obj):persistence.cpp:(.text$_ZL12icvCloseFileP13CvFileStorage+0x5a)||undefined reference to `gzclose'|
Build Log
C:\opencv\build\x64\mingw (static)\staticlib\libopencv_core2410.a(persistence.cpp.obj):persistence.cpp:(.text$_ZL12icvCloseFileP13CvFileStorage+0x5a): undefined reference to `gzclose'
If you have any advice for these errors, it would be greatly appreciated.
I have also been thinking that it is possible that I am going about this all wrong (I have a degree in electrical engineering, so I was exposed to a lot of programming; however, I may have missed out on some basic software engineering components.)
Here are some other things I have considered:
Using Visual Studios - The libraries for opencv are precompiled and also the target computers run windows so this might seem logical - I experimented a little bit and became frustrated with Visual Studios. I am becoming a Linux enthusiast and do not want to waste time learning windows specific programming.
Use Visual Studios Compiler in Codeblocks - The only option in Codeblocks is to use Visual C++ 2010 - I can't seem to get to get VC11 or VC12 to be used in CodeBlocks. Also, I see Visual C++ installed, but can't seem to locate its folder. (In Summary, I tried a few things that didn't yield immediate positive results)
Use an installer - I don't have experience with installers, but perhaps it is easier than trying to link libraries into an exectuatble. I am under the impression that one can set up an installer to store all dependencies in Program Files and put a shortcut to the executable in a convenient place. Is this the case, and what degree of difficulty is involved?
Manually organize a portable folder with dependencies. Not much experience with this, but again, maybe easier than linking libraries.
Please feel free to comment on the other options or provide any solution that I may be missing.