How to make my CPP console app installable/redistributable which depends on some external files? - c++

I am new to this coding world. So forgive me if any dumb question is asked or I made any mistakes
I am making a cpp tool which works well on my machine & also on others too. But inside it there is a function which works with some BAT & VBS files stored in a separate folder. Now the problem is when I am sharing the EXE file it is not working as the folder directory can not be found on other devices.
Now how can i solve this scenario? Is there a way to make installer for the console app which will copy the necessary files and folders in to the user's C drive? Or can I include the files into the EXE and extract them to a folder so the the program can use those?
Is there any possible solution for this ?
I am using Visual Studio Code & mingw gcc compiler for building the app

How about creating installer using setup creator(https://installforge.net). You can package multiple files in the installer and select installation directory to something like c:/program files/your_application_name.
That way your executable and other files will be in the same folder and it will also create a start menu shortcut

One straightforward solution I can think of is to include the dependency files with the exe when you share it to others.
Another way is to embed the dependency files as resource files into your executable when you build it in Visual Studio, then extract them when you run the exe (A little difficult to implement)
Or just create an installer like this

Related

Writing an Installer that contains .exe files, which it then runs/extracts, using C++

I'm trying to write a custom installer for a project, which acts like a one in all .exe.
The project persists of a mariadb installer, a xampp installer and some other php files.
I want the result to be a single executable file which contains both of the installer files and all of the other files, which it then extracts and does futher stuff to, which isn't important for the issue.
The .exe files are just for temporary use while they are installing their content via a silent install.
I read about the concept of embedded files but didn't find working examples of that for visual studio 2022.
What would be a good approach to archieve that?

How does Visual Studio and Github work together?

For example: I'm making an SFML game and I want to store my project on GitHub so my team members can have access to it. Since its made in Visual Studio does that mean I need to include: Solution file and .vcxproj file?
Also, I've seen projects on GitHub have a "src" folder to organize their repository, since mine was created in Visual Studio does that mean I need to rename my folder that is named after my project to "src" and reupload it? Or are people doing some sort of organization trick I'm missing?
Since the game is SFML, all my binaries (.dll) files are just thrown into my main folder of the project, I'd much prefer to throw them all into their respective folder, but if someone downloads my project does that mean they need to pull it out of that folder and throw it into the project file? (That way visual studio can find them)
TLDR: I'm having trouble organizing my GitHub repo with a Visual Studio C++ Project.
Since its made in Visual Studio does that mean I need to include:
Solution file and .vcxproj file?
Yes, you'll need to include solution and project files. You can see which files you can ignore at gitignore.io. Or, you can use cmake.
I'd much prefer to throw them all into their respective folder, but if
someone downloads my project does that mean they need to pull it out
of that folder and throw it into the project file?
Yes, each collaborator will have to download libraries and make it available to project on their end. And if you have lots of libraries and libraries depending on other libraries, updating them can be painful.
I use cmake and vcpkg. It isn't as straight forward as keeping libraries in project folder but requires reasonable effort for keeping project organized and clean. I'll recommend this approach.

NetBeans 8.0.2 "no executable specified in project"

I am working on a c++ application and it builds just fine but upon running my main class NetBeans complains that no executable has been specified in my project, it then asks me to provide a path to a .exe file? What is an executable and where can I find it?
An executable is a file that can be executed. A .exe file is one kind of executable. In general some people would include .bat files, .com files, .jar files with a main class in the manifest, scripts in various languages etc as executable files. In Linux/MAC executable files often have no extension at all.
However, if you are on Windows building with C++ the file you probably want is a .exe file.
If you create a new C++ Application type project it should already know which file to run since it will be setup to create it. If you create a project with C++ Project with Existing Sources then the project could create multiple executable files or none at all if the goal was just to build a library. This depends on who ever authored the external Makefile or whatever that project uses. If you don't know and can't guess from looking at the directory ask whoever created the original project or consult their documentation.

Handling images and sound files for a simple C++ project in Visual Studio

I am new to Visual Studio, and I am trying to figure out the best way to organize my projects.
I am writing an application using the sfml library, and I have various resources (images/sounds) that I am using. I dropped these into the project folder, and everything works fine when I launch my application from Visual Studio.
I am wondering though, how does this translate to when a program is deployed? If I go into my solution's debug folder, and try launching the exe, it is unable to locate any of the resource files. Am I suppose to tell Visual Studio to copy files to an appropriate directory, and if so how?
Thanks for any advice or links.
For slightly more complicated "deployment" scenario, you can use post-build scripts to copy the correct files into the output directory and even package it into a zip file, for example.
If you find yourself writing more than one page of batch you may want to consider the options below, because batch is a PITA to debug.
Recent MSVS project files are actually MSBuild files (just open the .vcxproj file in Notepad or Vim). For instance you can use the Copy task, invoke arbitrary programs using the Exec task, etc. It can be a bit more sophisticated than the batch script in post-build scripts. MSBuild 4 can use Property Functions making it quite expressive. Useful reference if you do this
For a "full blown" project, you'll want to roll a dedicated build system using a dedicated MSBuild file, NAnt or even higher level wrappers like Rake.
As a less popular alternative, in a previous project I built a small dedicated "builder" .exe project in the solution and have other projects depend on it. Then in the post-build scripts of the other projects I just invoke the builder projects with arguments to make it perform certain tasks. The advantage is that you can write C# (or F# or VB.NET) and not have to fight the build system (as much) and I think it works quite well for small-mid sized projects.
for my project, I direct everything into one directory.
Go to ur project configuration, change General->Output directory, General->intermediate directory, and Debugging->Working directory to one directory. The reason you cannot locate the resource files is because the debug directory is not the same as the output directory.

Making a GCC based Project Build and Run under Visual Studio 2010

I have been trying to port my C++ based mass data transport protocol project into visual studio 2010 with no success :(
The code I have been working on is fully compatible with Win based systems..well this is what my mentor also says :) But I have not been able to make the project build and run using my existing *.h & *.cpp files under VS 2010.
The Project basically is a API under which i have 4 separate applications. The hierarchy would be:
SRC FOLDER- all the *.h and respective *.cpp files
APP FOLDER- 4 applications (the API / library and some *.h files to be available before linking such as the final dll file under SRC folder & the main header file under APP folder)
I do also have a makefile as when the project was developed on Linux platform but I have no idea how to implement the same on Visual Studio 2010
FYI: VS 2010 on compiling reports that there are missing header files such as <cstdlib>, <unistd> but my best bet is this is not the real prob. but the prob. lies in the way I make the project build itself. I don't know should I go with making a dynamic dll project for the main library and then make the 4 empty c++ projects inside that for the 4 respective applications..?
Cheers,
echo9
I would recommend that you parse the data that you need from the working .mak file that you used previously. Create an empty project & sln, then add the contents of the "src" by using "add->existing files" in the file menu.
At that point open up the project configuration settings and go through the C++ and linker settings one by one. At each step have a look at the linux .mak file and see that you are choosing equivalent options and path settings. In particular make sure that you add all of the necessary include paths to where your .h files are.
That's what I would do anyways... same process as porting forwards old MSVC4 .mak projects to a modern version.