Creating an executable application with static libraries (OpenCV, DLib) on Visual Studio
I am using Windows 10, Visual Studio 2017, Opencv 3.4.3 and Dlib 19.16. I am creating an annotation tool for labeling certain data, everything seems to work fine. My only concern is I am not able to create an executable (.exe) file for this application which is built on static libraries and is self sufficient. Any help with this? Thanks!
well, obviously, not so ;)
well, tell us why it is so ! we need to see, what you try to link, how so (order matters !) and the errors you get
"everything seems to work fine" by this I mean there are no errors in running code. Only issue is the libraries are dynamically linked, so whenever I try to use .exe file of the project outside Visual Studio environment, It throws errors like "Unable to open shape_predictor_68_face_landmarks.dat for reading."(From dlib face detector) or "The code execution cannot proceed because opencv_world343.dll was not found. Reinstalling program may fix the problem.". Sorry if the question was unclear. This is my first time posting question here, so forgive my errors!
You can't.
@ameyparanjape -- that's not a linking, but a runtime problem. the path to dlib's dat file is either wrong, or the file is broken.
main problem now ;)
please update your question (maybe clean it up a bit), show the code, that tries to load it, and the directory structure (you can use the tree program :)
@berak I had no issues running the same routine when I did it inside the Visual Studio project (i.e. when I run .sln file), it was built successfully, and I could even use it to annotate images. So definitely the path to dlib .dat file is not wrong. I will update my question. The errors only show up when I try to run .exe file outside the Visual Studio environment or on any other Windows system which does not have opencv and/or dlib. Thanks!
ok, "wrong" is probably the "wrong" word here ;)
and indeed, relative path will differ, when run from an ide or not. most noobs get bitten by that ;)
So, I would like to know, if this is even possible at the first place that, I have a Visual Studio C++ project that uses OpenCV and Dlib. I want to make it into an application(.exe), which can be executed on any Windows system regardless it has Visual Studio, Dlib, OpenCV installed on it. @supra56 said straight NO
this means, you did NOT use static linking correctly !
even IF you link it statically, all it means, it no more depends on further opencv dll's. there are still windows system libs, the vc runtime, it was compiled against etc. it's far easier, if your program was built on an older windows vversion, and you try to run it on a newer one, than the other way round
@ameyparanjape. I don't know if this could help exe
@ameyparanjape I think you can download this wxOpencv20171203. It's an opencv application in static : no dll except opencv_ffmpeg
If it works then you can try to build opencv in static using https://github.com/LaurentBerger/wxHi...