Why continue using extensions .bat instead of .cmd? [duplicate] - build

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Windows batch files: .bat vs .cmd?
I know that the .cmd is the successor of the .bat (.cmd files use 32-bit execution while the .bat files use 16-bit execution) but most repositories I see on github that have a build script for windows continue using .bat extensions for build files.
As a general rule, anything you can do in a .bat file you can do in a .cmd file, but the reverse is usually not true.
There is a reason to use .bat instead of .cmd for build files?
Edit:
To clarify the difference between the extensions:
Windows batch files: .bat vs .cmd?

Two reasons come to mind:
cmd files have not been well publicised and I suspect a majority of people who use batch files do not know of their existance. I did not and I use batch files on a regular basis, and have for close to 15 years.
Of those that do know, batch files have the benefit of being backwards compatible. There is not a lot of direct benefits to using cmd files but allowing the same batch file to be run on practically any version of Windows and even DOS without any changes.

Related

Building in txt files into a single C++ exeucatble

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!

Deploy Qt application on Linux [duplicate]

This question already has an answer here:
Deploying Qt applications in Linux properly
(1 answer)
Closed 4 years ago.
I have created a nice little scientific Qt application and I want to distribute it.
It was very easy to do this in Windows, I simply created a folder, put my executable there and called the windeployqt program, which put all necessary .dll files in the folder like Qt5Core.dll, Qt5Gui.dll, Qt5Charts.dll... and it created some subfolders like iconengines/, imageformats/, platforms/ and many more.
All together this folder now contains 43 files.
When I copy this folder to any other computer with Windows 10 it runs well.
I would like to do the same on Linux, because it is the preferred operating system that we use.
However, I struggle a bit because I do not really know how to start.
Is it possible to do it the same way? Copy all necessary libraries in a folder together with the executable and simply be able to copy it on a different computer with Linux and run it?
(To clarify: When I say Linux I mean Ubuntu 18.04 or 16.04)
Or is there a different way how to do it?
I only have a students license so I think I'm not allowed to statically link the libraries (but I have to read the license terms again to be sure)
In case it works the same. Is there a simple way to copy all necessary libraries in this folder? Or do I have to search the 42 libraries by myself?
I have read the manual but to be honest I did not understand everything and all the example codes in there.
Thank you for your help.
Look at the Creating the Application Package link in the documents. For Linux, a starting script is given to you via documentation as a starting point. Here it is:
#!/bin/sh
appname=`basename $0 | sed s,\.sh$,,`
dirname=`dirname $0`
tmp="${dirname#?}"
if [ "${dirname%$tmp}" != "/" ]; then
dirname=$PWD/$dirname
fi
LD_LIBRARY_PATH=$dirname
export LD_LIBRARY_PATH
$dirname/$appname "$#"
This script must be saved as an .sh script and must live in the directory of your executable.
Make the script executable , open a terminal and do the following:
$ cd /pathToScript/
$ sudo chmod +x scriptName.sh
Then double click on your script to run.
As stated in the Qt docs this will make:
...sure that the Qt libraries will be found by the dynamic linker. Note that you only have to rename the script to use it with other applications.
If you want to statically deploy your project, you must first have a static version of Qt built from source, that can be found at this headline from the Qt Docs.
A couple more notes: If you want to distribute this project for it to be used on a Linux system. You can simply package the build folder. But to actually run it, you would need to use the script (for the easy way at least) on a Linux system. It is not necessary to go hunting for the application's dependencies.
You need to install all qt libraries first.
I think using qmake could be a solution if you're creating a Qt-based project. Qt Creator uses it as default.
qmake generates all needed files used to compile the program. Try using it.

How to run CMD script instead of building and starting C++ console application?

I created a Win32 C++ console application. I want to run some CMD scripts instead of building and running this app. How can I do that?
Exactly what commands do you want to run?
Depending on the complexity of your logic, it's ok to scrap your Win32 C++ console application and just use "Batch files". (That's assuming you are running on a Windows operating system that is Windows 7 or earlier versions).
Batch files have a myriad of operations and operators that you can use to execute commands and even has some logic structures and ability to pass in parameters and call other batch files as if they were sub procedures.
You'd do best buying a book on Batch files.
Also you can google:
"Batch files",
"DOS Files", and
"Win32 Shell Scripting" to get tutorials on all the in's and out's of writing a batch file.
You can use any text editor to write a batch file (like note pad, etc). In order to make it a batch file, you name the file with a .bat extension.
By running the batch file in a command prompt window, the computer will execute the commands in the file as if you were typing them into the prompt yourself.
The one drawback is that Batch files are much slower than other compiled languages. But if speed and memory size is not an issue, then there is nothing wrong with using them.
Give us more details if you want more of an explanation.
Best of luck :)

C++ Embed external .exe into my compiled .exe

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.

Adding a text file to an exe generated by PyInstaller

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