Create a completely .exe with opencv in Visual Studio - visual-studio-2010

I was creating a project in Visual Studio with OpenCV and it runs fine. But I cannot just run the compiled .exe file to another computer. Because it does not have opencv or c++. So please help me on how to create an installer program so that the computer does not have to install opencv or c++ and running the project?

Just use Dependency Walker tool to find dlls your program depends on. Find the dlls on your system, and copy them to your program distribution (to folder that contains executable file).

Related

missing dll errors after creating installer for my project in Visual Studio 2010

I have a fairly large project in Visual Studio 2010
I can build the project in both Debug and Release mode, copy the generated exe file along with a custom dll I need for a function in the program to another computer, and the exe file works without any problems
I am trying to make an installer for this project in Visual Studio 2010, following the instructions here: https://www.technical-recipes.com/2011/how-to-create-an-installer-in-microsoft-visual-studio/
I do not get any errors while building the installer, and I get a setup.exe and an msi file as a result, but if I install my program in another computer (not by development machine), when I try to run my program after installation I get a missing api-ms-win-crt-runtime-l1-1-0.dll error
How do I debug this problem? Since I can simply copy my Release or Debug build to the computer and make it work, doesn't it mean all the dll files my program is dependent on already exists in the other computer? And if this already works, why isn't the installer version working? How do I make sure that everything I need for this program is included in the installer?
My project in MFC dialog based and uses one third party library, for which I have both .lib and .dll file available. I need to do this in Visual Studio 2010. My development machine is Windows 10 64 bit Home edition version 1909. The installer I currently create installs my program in Program Files (x86) folder.
Static Linking MFC: It appears this issue was solved by making sure to statically link to MFC libraries. In the VC++ project: enable the setting: "include MFC in a static library". This enables static linking of MFC components, eliminating the dependency on shared dlls.
This is a common "missing runtime error" - there are generic check lists below which include this as one source for application launch problems.
Warning: Generally static linking should be avoided in order to benefit from security updates to shared dll files via other update mechanisms.
Short Version: In Visual Studio Installer Projects, check if the Visual C++ Runtime is available in the Prerequisites list.
See this answer, here is a quick screen shot:
Tools: If your project is large you might want to consider another MSI tool. There are many limitations with Visual Studio Installer Projects.
Merge Modules: There are merge modules to install the Visual Studio C++ Runtime, but it is recommended to use the setup.exe for these reasons.
Visual C/C++ Runtime: You are probably just missing the Visual Studio C/C++ Runtime. It needs to be deployed with your application, it is not on there by default (unless you link statically, in which case it should not be needed). Skim this list quickly for other ideas.
You can download the VC++ redistributables at ("The latest supported Visual C++ downloads"):
https://support.microsoft.com/en-us/kb/2977003
More Information:
More on the Visual C/C++ Runtime
Secondary Links:
Detecting presence of Visual C/C++ runtime on box
Missing Dependencies and check lists
Scan for application dependencies
Installing VC++ Runtime with merge modules

How to build a portable program by visual studio

I am using visual studio 2010 under Win7-64bit to build an application with openCV. I finished development and build the release version without error. I also successfully run the program in debug mode. I then move the .exe file to other directory in the same computer. I run it in cmd.exe and I got error warning: Error opening file <../../modules/highgui/src/cap_ffmpeg_implhpp:537>
I guess there are some dependence with some libraries of openCV but I don't how to solve it. My final task is that I can use that .exe in another computer under Win7 directly. How to do it?
I found a similar question here. But I don't have .dll file built, so what should I do to solve this problem?
Building an OpenCV app with shared libs (DLLs) require the DLLs to be available (same folder or in lookup path) to the exe when it is run.
If you are using static linking then you don't need any of the OpenCV DLLs to be reachable. However, due to licensing issues, ffmpeg is linked dynamically even when the rest of the libs are linked statically, and thus, you need to have the ffmpeg DLL available for the exe. It is called something like opencv_ffmpeg*.dll.
Note that this is only needed if you are using highgui related functionality.

Find visual studio version on which the exe was build, from the MFC exe

I have a exe which is made in MFC. I want to find out on which visual studio version the exe was build.
Try CFFExplorer from http://www.ntcore.com/. This small program tells you a lot of interesting things about a windows executable and does quite a good job guessing wich development environement has been use to create it.

mupdf utilities compiled on Win8 with VS2010: are the exe's executable on every Win system?

I compiled the mupdf command line utilities on Windows8 with Visual Studio 2010 Professional with the included VS projects. They work. If I want to move them to another system (any Windows) is it enough to move the exe's?
You can move them as long as they are compiled in Release mode. If they are in Debug mode the target machine will need Debug VC libraries installed. Release libraries are usually present on all machines.
My guess is: yes. Provided that you don't move a 64bit-exe to a 32bit Windows. And provided you move any *.dll files which were compiled alongside the *.exe with them. -- Why don't you just try it?

Adding libraries to Visual Studio problem

Can someone link me a good guide for using libraries in a c or c++ project?
Right now I'm trying to add OpenCV to a newly created project. I've added all the directories I can think of in "Project and Solutions -> VC++ Directories" and to make sure I've dragged and dropped all the .lib and .dll files into the project.
The project builds but when I run the simple "Hello, World program" it gives me this error message:
"cv.exe unable to locate component.
This application has failed to start because cv200.dll was not found. Re-installing the application may fix this problem."
How can I really add this cv200.dll? I've dragged&dropped it into the project..
Thanks!
You need to make sure that cv200.dll is in the DLL search path at run time. The easiest way to do this is to put it in the same directory as the built executable. Dragging and dropping a DLL or LIB file into your project has no effect.
MSDN has a good description of the full DLL search order when loading libraries at runtime.
By default during installation OpenCV create env. variable path \bin.
All dll assumed to be in that dir. However you are using OpenCV 2.0, and OpenCV 2.0 installation doesn't include lib and dll files for Visual Studio. You seems already built all dll's and lib's. If you installed OpenCV correctly just move all dll's into \bin (for example C:\Program Files\OpenCV\bin)
If for some reason you are missing some dll or libs here is instruction how to build them
http://mirror2image.wordpress.com/2009/10/20/switching-to-opencv-2-0-with-vs2005/

Resources