Create dll which uses OpenCV classes and functions for project

asked 2018-05-01 07:20:45 -0500

I am writing a project for shape manipulation in Visual Studio 2015, and I want to create an executable of the project so I could run it on another computer without OpenCV installed.

The only method I know of doing so, is Build -> Release in VS, and then the .exe is located in: Project\x64\Release path.

The problem is that to run the project without opencv on another computer, I need to copy opencv_world331.dll to the .exe path, but I assume that the dll contains all the library functions and classes, and not just what I am using.

Is there any method to create a dll which contains only what I am including, and not the whole library?

This is the .h file of all my opencv imports:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

using cv::Point2f;
using cv::Point2i;
using cv::Point;
using cv::Size;
using cv::Mat;
using cv::Scalar;
using cv::Rect;
using cv::RotatedRect;
using cv::Vec4i;

using cv::circle;
using cv::putText;
using cv::line;
using cv::namedWindow;
using cv::imread;
using cv::imshow;
using cv::waitKey;

using cv::THRESH_BINARY;
using cv::WINDOW_AUTOSIZE;
using cv::FONT_HERSHEY_SIMPLEX;
edit retag flag offensive close merge delete

Comments

you can try to build the opencv libs locally, using

cmake -D BUILD_opencv_world=OFF

this will result in 1 dll/lib per opencv module, opencv_core, opencv_imgproc, etc. then link only those you need

you also could try to build static opencv libs (no dll's nessecary then), but you'd also have to link the windows libs, opengl, zlib, etc. manually (and in the correct order !) in your project.

berak gravatar imageberak ( 2018-05-01 08:50:24 -0500 )edit