Search code examples
visual-studioopencvstatic-linking

MS Visual Studio 2012: build statically linked exe


I'm using visual studio 2012 and C++ and I'm tying to build a fully static executable of my program. It uses OpenCV 2.4.6 and I wish to be able to run it on a machine without any OpenCV (or even the standard c++ library) installed. I tried to follow every guide on the argument but i couldn't get around it, so here I am.

Thanks for any input!


Solution

  • dont have 2.4.6 but should be exactly the same

    • build opencv with BUILD_SHARED_LIBS off
    • set vs2012->project properties->c/c++->code generation->runtime library->multi-threaded(/MT)
    • set linker input to following
        opencv_core245.lib
        opencv_contrib245.lib
        opencv_features2d245.lib
        opencv_objdetect245.lib
        opencv_nonfree245.lib
        opencv_highgui245.lib
        opencv_flann245.lib
        opencv_imgproc245.lib
        opencv_video245.lib
        opencv_legacy245.lib
        opencv_gpu245.lib
        opencv_ml245.lib
        IlmImf.lib
        libjasper.lib
        libpng.lib
        libtiff.lib
        libjpeg.lib
        zlib.lib
        Vfw32.Lib
        comctl32.lib