2

I'm really new in using OpenCV C++. Is there any possibility to configure my VS 2013 to configure my project to use only *.lib instead of *.dll ? I don't want to add to my final executable any *.dll files. I heard that *.lib files will during compiling just insert (sorry for this word) into this executable instead of many *.dll files around.

I was following this manual, especially the end of this with some INSTALL project. I did every step from this manual, but... It doesn't work. (I can compile testing project - here), but it always said "I can't find *.dll file and program can't run."

Thank you.

Martej
  • 55
  • 1
  • 6
  • you are talking about static linkage http://stackoverflow.com/questions/16830842/using-static-libraries-instead-of-dynamic-libraries-in-opencv – baci Aug 12 '14 at 19:37
  • http://stackoverflow.com/questions/6579535/how-to-embedd-opencv-dlls-in-executable?rq=1 – Martin Beckett Aug 14 '14 at 05:27

3 Answers3

3

you could try static linking. but it makes the complied executable much larger and takes longer to assemble all the parts into one single executable.

it can be achieved by setting the use shared library(i.e. dll) flag off. cmake -DBUILD_SHARED_LIBS=OFF

James Harper
  • 480
  • 4
  • 8
  • Thank you, problem was with configuration of VS 2013. And you are right, size of executable growed ~2MB. Can it be fast as executable with linked *.dll ? – Martej Aug 14 '14 at 07:33
  • @Martej yes. unless you want to ship your product in a single executable, using dll is always advisable. Not only does it compiles faster but also starts faster, because you are sharing the library that might has been already loaded into memory by other program. – James Harper Aug 14 '14 at 07:42
0

As far as I know, there is no way to avoid using the *.dll file. Also I guess you are trying to run your project from the VS2013 GUI. The problem is that without seperate configuration the executable expects all *.dll files at it's location.

VS locates your project's .exe file in /project/debug/.exe (or release depends on settings).

The "INSTALL" project however normally creates a seperate folder where your project is being "installed".

So you either copy your *.dll files into the project's build folder, or you build the "INSTALL" project every time and start the *.exe from the specific "install" folder.

Die Usche
  • 132
  • 10
0

I think you can set [Build]->[BUILD_SHARED_LIBS]->value unchecked

bruce
  • 1,286
  • 11
  • 14