I don't know if it is a stupid question, but I want to know: Is there a way to build in some .txt files into a single C++ .exe?
What I mean by that, is, I want compile some .txt files into a single executable (.exe), so I don't need to depend on other files on the front end. Therefore, I only need to distribute a single .exe file and put it in any directory without the hastle of having to move a whole folder and making sure the executable is either ran from the command line or has to be in the root of a folder. I am doing everything in C++.
Hope I made my question clear, thank you in andvance for answers amd opinions!
Related
I'm pretty new to VsCode. So the problem is whenever I create a new C++ file and run it, an exe file is created with the same name.
Here's the picture,
So if I have many C++ files, there will be also many .exe files that are not clean to see and distracting.
Is there anyway to get rid of this exe files? (If not completely, atleast out of my sight)
If these files keep creating every time you run the code, you can go to Settings in the bottom left corner and search for Files:Exclude. Then you have to Add the **/*.exe Pattern. It makes all executable files hidden in the Explorer section.
I'm relearning C++ after many years of higher-level languages. I've been googling around in circles for a while now on this. One issue with googling for answers in C++... "how do I include .h in my build output" just returns a bunch of results on how the #include statement works (not quite what I was looking for google... thanks...).
In visual studio, when I run a build, the output folder contains
mydll.dll
mydll.tlb
mydll.xml
I know header files are required to import the DLL into another application, but I'm not sure on the process.
Do I just copy/paste the .h files into the output folder? What's the canonical way to automate this process in VS?
Is there some step I should be taking that adds them to the output?
Should I really be shipping it with multiple .h files, or is there some way I'm supposed to combine them into one large mydll.h file?
Am I correct in my understanding that .lib is only generated if something in my library is static?
Is there a good guide for creating a production build somewhere out there?
I appreciate the advice!
I have a quick question on a topic that I'm quite a noob about. I have a program I made that sends a command to another .exe in a folder I called "tools". I send it in this format:
system("tools\\program.exe -r -w file.dat file_new.dat");
Everything works great, however, when I build my program into a .exe it will require the other executable to be in a second folder, obviously. Is there any way to include the external .exe into my project so the final product is just one .exe?
I am using Visual Studio 2008 (lol) and run windows 7 64bit.
Thanks :)
Typically, the management of external dependencies would be handled by the installer. NSIS is my favoured solution for the Windows platform.
The alternative: Convert the binary to a base64 encoding and embed it as a header file in your project. When the application is run, convert the base64 representation of the exe to a binary sequence and then output that sequence of bytes to a file in a temporary directory (like C:\windows\temp or %AppData%\Local\Temp). Then run the exe. Once you're done with it, remove the exe.
You can add the file to resources. And before the command is executed, you can check, if the second executable exists. If it doesn't exist, you have to extract the data from resource and store to the file...
This thread was dealing with reading html from resource. It is very similar with binary file.
I have a rather interesting problem I've been trying to find a way to solve, and as of the moment, I have not found a solution to. I currently have built a GUI program using Python, and more specifically using Tkinter, which will generate a file with a list of commands to be repeated by my program in the specified order while waiting however long is specified. It's basically used to create a macro, which is recorded in a file and can be ran later using another function in the program.
What I would like to add to my program is a manner in which to create an .exe file, which is a standalone file, that can run a script from within it. The reason I can not find a good way to do this though is because I need for it to be created on the fly. What I was thinking I'd like to do is generate an .exe(Standalone macro exe) with PyInstaller ahead of time, and package this in to my main .exe also using PyInstaller. When you choose the option to create a standalone macro, it would proceed to get the .exe(Standalone macro exe) which I had packaged in to my main .exe from the directory in which it was unpacked in to when the program was run, copy it to the desired location for the standalone exe to be saved to, and then copy the script the user wished to be run as a standalone and package it in to the standalone exe.
I have no idea how to go about this, because I'm not sure exactly how PyInstaller puts the files in to a .exe when it packages it. Because of that, I wouldn't know how to add a file to an existing .exe using python.
Basically what I need help with is how I might go about adding a text file to an .exe generated by PyInstaller.
Ummm,
Could you clarify something...are you thinking something like Perl's (25th birthday today) (camel book by Larry Wall, p44) handles or a Bash HERE document ?
Update (based on discussion below): This will integrate python files and other externalities into a single installable:
http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html?format=raw#create-a-spec-file-for-your-project
http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/images/SE_exe.png
I want to compile a batch file into an EXE file using C++. I can get through parsing the batch file and writing a new .cpp file. But I don't know how to compile the new .cpp file into an EXE file for the end user.
OK, here's the thing, I am creating an application in DevC++ that will read in a batch file. Then, one by one parsing it using:
system(getline(myfile,line));
After setting everything up, I save the newly created file as "main.cpp".
The problem is, I want to compile it into an EXE file, from my program, for the end user.
So basically, can I compile a C++ file from a C++ EXE?
Yes, you can provided that the end user has a C++ compiler installed and you're emitting valid C++.
Depending on the compiler you're using, your C++ executable would have to spawn a process that runs
cl main.cpp
or a similar invocation of the compiler after finishing the translation.
If your user doesn't have a compiler installed, then you're pretty much out of luck - trying to build a C++ compiler yourself is a rather non-trivial exercise.
The short answer is no. Unless you are willing to write an entire C++ compiler, you will need to invoke an external C++ compiler to compile that .cpp file.
On the plus side, if you are simply looking to convert .BAT files into .EXE files, there are several existing solutions, such as quickbfc.
Can I ask why do you need to parse bat file?
I mean if you are taking input or something from that file then can you try to use a database or something for that?
Also for the user end you can write web application to display output.
There`s C++ Server Pages equivalent to JSP, PHP which can use C++ classes.
Am I helping here or this is not what you want? may be if you can describe you application use somebody can help you better.