Compile from Compiled

1

I have an application that uses the command line below to pass the arguments to the compiler and thus generate an .exe (in the case of windows) already compiled.

I want to publish the application, but each person may have the compiler in a different path, so I wonder if there is any way to generate an .exe (or compiled) from the application itself without resorting to the command line compiler .

Thank you!

    
asked by O.Palm 11.07.2018 в 09:45
source

2 answers

2

Compiling the code requires, by definition, a compiler. Either use an external one or attach one to your application.

  • If you use an external compiler, it would be for your application to read a configuration file in which the user can indicate where the compiler is (imagine that it has several installed), what type it is and another important information so that your program can speak correctly with the compiler. The complexity of this solution is that your application can speak correctly with different compilers (in the image and likeness of any modern IDE).

  • To integrate the compiler in your application you could store the binary in the form of an array of bytes (you would have to use several arrays since compilers usually use several libraries). Then your application could generate the executable by saving said array in a binary file. The problem with this solution is that the compiler may not work properly with some operating systems due to incompatibilities. Another problem is that you will have to read the compiler's licenses to choose one that is compatible with this form of distribution.

  • A third option would be that you distribute the compiler next to the executable, that is, in the same package you put the two executables. Then you could assume that the compiler is going to be in the root of the application (or wherever you want to put it). The problems you face with this solution are the same as in the previous case.

answered by 11.07.2018 в 10:18
2

No There is no way to generate an executable from the application itself without resorting to the compiler by command line: the compiler is an executable and requires to be invoked, surely by means of a call to system .

I see that you have tagged the question with , so I assume you intend to use the compiler of . As you indicate, " each person may have the compiler in a different route " but this has already been taken into account by the Microsoft team, which has prepared a guide configure the compiler by command line (highlighted by me):

  

When choosing one of the C ++ workloads in the Visual Studio installer, install the Visual Studio platform toolset . A set of platform tools has C and C ++ tools for a specific version of Visual Studio, including C or C ++ compilers, linkers, assemblers, and other compilation tools , as well as libraries Match search. You can use all these tools on the command line , and they are also used internally by the Visual Studio IDE.

  

To work properly, the tools require several specific environment variables to be set . They are used to add them to the path and set include SDK locations, library file and files. To make it easier to define these environment variables, the installer creates custom scripts , or batch files, during installation. You can run one of these command files in a command prompt window to set a specific host and target compilation architecture, version of the Windows SDK, target platform, and the platform toolset .

  

The required environment variables are specific to the installation and the compilation architecture you choose and you can change the product updates. Therefore, it is recommended to use one of the installed symbol shortcuts or command files instead of setting the Windows environment variables .

Proposal.

It is going to be necessary to follow the configuration guide on all the machines that you want to launch the compilation, once the destination machine is configured to compile: make the call system to launch the compilation.

    
answered by 11.07.2018 в 12:17