Build all dependencies to one file - c++

I'm working on a small installer program (silent install of setup, unzipping, ...).
I wondered how to build everything into one .exe file.
I don't even know HOW to search for that correctly.
Could you tell me some keyword to search for?
E.g.:
I have Setup.exe and Configs.zip for my installer to use.
After compiling I just wanna have 1 file (Install.exe) which has Setup.exe and Configs.zip included and can use them.

You could use resources that is a normal way to store such files. You can extract that files and execute that than from the temp directory.

Related

What cpp file types can I delete/exclude when packaging into an install bundle?

I want to package my executable file and other needed files into an install file (using NSIS) so that other people can install and use. There are a few file types I am uncertain of whether they are needed for installation or if it is safe to delete them.
Here is a random example of the files in the project folder as well as the Debug file automatically generated by VS:
I have already deleted the .user file as I know that is not needed, but not sure when it comes to .vcxproj, .tlog, .build.cppclean, .idp, and .pdb files. Also, do I need to keep the .obj files as well as the .cpp files?
This is my first time trying to do this, I am just messing around to seeing how it all works so thanks in advance.
You generally only need the .exe. Your app might depend on custom .dlls or the C++ run-time library in which case you would bundle the custom .dlls and/or the C++ redistributable.
Your screen shots are of a debug build and you normally want to distribute a release build instead because it is often smaller and contains more optimized code.
.obj files contain the machine code for each source file and is used by the linker when it merges all the required code into your .exe.
.pdb files contain debugging information. You should not distribute them but it is helpful to store them for yourself in case you need to debug a released version of your application.
The rest of the files in Debug and Release can also be ignored.
If your project is open source then you could include the c/c++ files and the Visual Studio project files. Or you could just upload them to Github.
In NSIS you could do something like this
InstallDir $ProgramFiles\MyApp
Page Directory
Page InstFiles
Section
SetOutPath $InstDir
File myproject\Release\MyApp.exe
File mylibrary\Release\*.dll
SectionEnd
It is a good idea to test your installer on a freshly installed Windows instance. Ideally the minimal version you require, Windows 7 etc. This should allow you to verify that you have included all the files required by your application.

how to make stand-alone setup file of a mfc project including all data files

I have a project in VC++ MFC and works fine with the .mdb files. But just copying the project's .exe file on other system does not let the project work as it searches for the same path as mentioned in the code for the .mdb files and fails to find one. Also, apart from .mdb files, theres a need for certain .ocx files and io library suite to be registered in the system prior to the project's execution. How to overcome this problem?
You need to wrap up all the files into a package also known as installer. One of the most popular (and free) at the moment is Inno Setup. This will produce a single exe file that you will be deploying to users / other machines. You need to make sure that you include all the needed files, libraries etc in your setup.

How do I set a lua.dll so lua.exe won't ask for it in every directory?

Every time I enter lua my_script.lua in command line, it prompts me for lua53.dll on the same folder. How do I set a path so I won't need to have a copy of the lua library in every folder that I want to run a .lua file? I wonder if it is made via parameters or if I should build my own .exe from the .c files using environment variables, but I don't really know.
I've downloaded the binaries from http://luabinaries.sourceforge.net (v5.3.2 - may 19th) and have put lua.exe inside C:/Windows/System32.
According to this MSDN article, the directory from which the application is loaded is the first location being checked for the DLL file. If you put the DLL next to the location of lua.exe it came with, the DLL should be found and loaded by the system.
It may be better to not put application files into your system folders. Just create a separate folder and put your Lua files (.exe and .dll) there. You can then add that folder to PATH environment variable, so that it can be found when you run it as lua.

How do I properly handle the location of resource files for a program using CMake

I have a C++ program that needs to open some XML files when it runs to gather configuration information about the system. I am using CMake to manage the build and deployment (RPM) and am trying to figure out the most elegant way to deal with installing these XML files and allowing my program to find them when it runs.
Ideally, this solution will:
1) Allow the program to run from its build location (for testing/debug mode) in which the XML files reside in the source directory
2) When the program is installed to /usr or /usr/local (or whatever) the XML files will be installed to /usr/share/somePath/ConfigFiles/ and the program will know to look for them there.
My current solution is to create a config.h.in file that defines the source path of the XML files and the install path (/usr/share/...). When the program runs it checks one directory and then the other. Is there a better way to handle this so that the program knows whether a "make install" has been executed and it will know exactly where to find them without having to check both locations?

How can a program create another executable file?

Basically I'm asking how do installers work. What is the code that creates a new executable file?
EDIT: It sounds like the answer I'm looking for is the files are stored in archives and the installer unpacks them.
An installer normally extracts an appended archive and puts it to the desired directory, registers some libs and so on.
Another Task of an installer is to detect if the needed dependencies are installed and install them if needed.