Distribute a binary executable of a program built with OpenCV? - c

I created a program in C that uses OpenCV. In addition to distributing the source and make files, I would like to distribute a Win32 binary that will run when an end-user clicks on it. Presumably I would need an easy way for the user to install the OpenCV libraries. What is the best way to do this?
Should I be looking into installers, like NSIS? Any tutorials or starting points would be greatly appreciated.

Just include the dll files of OpenCV along with your program. Put those files where your main .exe file is and it will run whether you have OpenCV installed or not.

Related

CodeBlocks cannot link allegro library

I'm a student at an university and currently tasked to do a project of any kind but resticted to using C. I chose to make a video games using allegro5 because it has all the function I need to fulfil my project. I managed to set up the library (I set up build option in the .cbp file) so that it would work for me and currently finishing the program itself. The problem is that, if I send my work to any other person, the allegro library doesn't link up and fails to start up the program. Also, when I try to start .exe file to launch the project on my own device, it also fails to link up. If this makes any sense, I need some advice with linking libraries so that anyone could launch the game from there devices without the need to setup allegro.
Thanks in advance!
You need to copy certain .dll files with your exe. If you place the .dll files in the same folder as your .exe, then it should work on other machines.
Which .dll files you ask? Well that depends on the exact variant of allegro that you got. There are variants, such as allegro_monolith-5.2.dll or allegro_monolith-5.2-debug.dll. And these dlls might have dependencies, such as zlib1.dll, libpng16-16.dll and others.
The dependencywalker tool can help you decide which dlls you need.

C code compilation

i want to compile a 'c' code and create an executable from my application. as of now i do it by specifying the path of my compilation .exe (c++) present in the bin folder of my Dev-Cpp folder.
it works fine but i need to pack the compiler along with the application so i wanted to know what files and folders are needed so that i can compile it directly from the application.
what are the files needed exactly i.e. headers,the compilation application, libs and what else...
any help?
If you're asking how to create and distribute a project which is able to build upon an existing compiler for its functionality, there are packages you can find which are just the compiler portion without the IDE. Minimalist GNU for Windows is such a package:
http://en.wikipedia.org/wiki/MinGW
(In fact, when the people who put together Dev-C++ wrote their integrated development environment, they get the actual compilation functionality from MinGW...which they bundled into their package for good measure. So if you were going to write an IDE of your own, you would start from the MinGW distribution...not by trying to hand-pick files out of Dev-C++.)
One issue to be sensitive to is licensing. While there are not generally any legal issues out of the box regarding distributing executables built with a system like MinGW, when you go as far as to include the compiler in your own "product", it might be tricky. Dev-C++ is under the same license as MinGW (GPL) but I'd imagine there'd be issues if it were not.
If you only need a subset of the full functionality (let's say you only compile C and not C++) there will be a lot of header files and such that you could cut out. But you have to trade off the difficulty of maintaining this sort of optimization vs. just having your program ask users to install MinGW and then tell your program where they installed it. It might take up more space and lead installation to be a two-step process...but frees you from a large number of concerns.
So that's what I would suggest: Have a setting in your program (much like Dev-C++ does) which lets people specify where the MinGW binaries are installed on their system. But let them install it independently.

Create exe file from tar.gz in linux

I managed to create a .deb file from a source program,tar.gz
how can i create an exe file so that the app can also run on windows?i've searched a lot but didnt manage to find any resources.
If you want to run the program under Windows, you'll need to re-compile it from source using a Windows compiler. How exactly to re-compile it will differ from program to program. Check the program's documentation for details or ask its maintainer. ".deb" files and anything else related to Linux package managers have no meaning in Windows, so you'll need to extract the source from the source .deb or pull it from the appropriate source repository.
Be aware that many Linux programs won't build for Windows with a simple recompile alone. If they use any external libraries, then those libraries need to be available for Windows as well. The Cygwin environment may help here. If there isn't already an official procedure for building that particular program under Windows, then you may have to do the porting work yourself (which is a large enough task that it's well outside the scope of this question).

Can i make a small program portable by statically linking all the libraries in vs2010?

I have a small program using imageMagick library. I added necessary library dependencies and set Runtime Library to /MT, and it complied and ran well on my Win7, but when it ran on another computer it asked for CORE_RL_Magick++_.dll !? What's wrong?
I intended to make a small portable exe which can run on others' computer, i thought the easiest and clean way is to statically link all the necessary library in one single exe so that others can just click-and-run. But the VS2010 seemed didn't do what i want.
Is it possible to statically link all necessary libraries ? If so, how can i get this in vs2010? Why the exe ask for dll after these configuration?
I was bothered for quite a long time, i would appreciate it if you can give me a hand.
VS 2010 has some changes in Projects settings including the static linking , you may find the proper way here http://blogs.msdn.com/b/vcblog/archive/2010/02/16/project-settings-changes-with-vs2010.aspx

Many files for a single program?

Typically, when I create a program (I have only made a few very simple ones so far) I compile the program into a standalone EXE. Most programs that are distributed nowadays have many exes, dlls, and other files that are installed when you first download the program. Is this wrong to be compiling my programs into standalone EXEs? What are some advantages/disadvantages to a standalone vs multifile program?
The only possible thing I can think of is for updating and fixes, because then instead of having to download a 100MB file and overwrite all user settings data, etc. you can simply download maybe a 400kb file that only replaces the files that need to be fixed.
DLL files are library files. If you are not using any functions from a library, then the DLL files will not be included with your program. Having multiple EXE files are generally a way to break a larger program down into smaller, more maintainable units.
If you're just getting started, this is not something you'll need to worry about just yet. One day, when you're working on a larger project that involves using other pre-built components, you'll dig around in your build folder and notice that you also have some DLL files and other resources.

Resources