Questions tagged [compilation]

Compilation is the transformation of source text into some other form or representation. The most common usage of this tag is for questions concerning transformation of a programming language into machine code. This tag is normally used with another tag indicating the type of the source text such as a programming language tag (C, C++, Go, etc.) and a tag indicating the tool or compiler being used for the transformation (gcc, Visual Studio, etc.).

Compilation is the transformation of source text into some other form or representation. The software tool used is called a compiler. Most compilers process the source text to generate some sort of machine code for a target hardware machine. Some compilers generate the "machine code" for a target virtual machine (e.g. bytecode for a Java Virtual Machine).

In all of these cases the compiler creates new files of the transformed source text and these new files are used in some other processing step up to and including executing directly on hardware or virtual hardware.

Interpretation is the processing of source text by a software tool called an interpreter. Interpreters immediately execute the sense of the source text without generating a new, externally visible form of the source text. Compilers generate a new, externally visible form of the source text which is then executed by some other device whether actual hardware or virtual machine.

The lines between interpreters and compilers have blurred somewhat with the introduction of languages whose tools generate an intermediate language which is then executed on an internal virtual machine. The traditional compiler generates machine code files which are then further processed into an application to execute. The traditional interpreter parses the source text line by line performing some action indicated by the line of source text at the time the line of source is read.

A C or C++ compiler generates object files containing binary code which are then processed by a linker into an application and executed. A Java compiler generates class files containing Java Virtual Machine byte code which are then combined into a Java application and executed.

Engines for scripting languages such as Php and JavaScript may use an internal compiler to generate an intermediate form of the source text which is then executed by an internal virtual machine. For some types of applications the intermediate form is temporarily stored or cached so that if the same script is being used by multiple threads or multiple repetions in a short time span, the overhead of rescaning the source text is reduced to improve efficiency. However these are not considered to be compilers.

Compilation usually involves the following steps:

  • Scanning - The scanner is responsible of tokenizing the source code into the smallest chunks of information (keywords, operators, brackets, variables, literals etc.).
  • Parsing - The parser is responsible with creating the Abstract Syntax Tree (AST) which is a tree representation of the code according to the source language definition.
  • Optimization - The AST representing the code is sent through various optimizers in order to optimize for speed or space (this part is optional).
  • Code generation - The code generator creates a linear translated document from the AST and the output language definition.

In many languages and compilers there are additional steps added to the process (like pre-processing), but these are language and compiler specific.

In most cases, where compilation is a part of the build/make/publish process, the output of the compiler will be sent to the linker which will produce the ready-to-use files.

Questions using this tag should be about the compilation process, not about how to write compilers for example (use the compiler tag for that).

17181 questions
6
votes
3 answers

Problems with static binding and dynamic binding in Java

I've read through some articles about static binding and dynamic binding in Java. And I have the following question (I've searched a lot but not found any mention about it yet): For example, I have the following lines of code: Person a = new…
DunDev
  • 210
  • 2
  • 13
6
votes
2 answers

How to initialize a set() in code to be compiled as pypy's rpython?

I want to compile some python code using pypy's rpython translator. A very simple toy example that doesn't do anything : def main(argv): a = [] b = set(a) print b return 0 def target(driver,args): return main,None If I compile it…
highBandWidth
  • 16,751
  • 20
  • 84
  • 131
6
votes
2 answers

GCC - Macro containing compilation flags

Is there any macro in GCC that contain compilation flags used to compile the program? I want something like this: printf("Compilation flags: %s", __FLAGS__); To output for example: Compilation flags: -02 -g
zupazt3
  • 966
  • 9
  • 30
6
votes
1 answer

Should standards be specified in source code or in CPPFLAGS?

Is it better to #define _BSD_SOURCE or to set CPPFLAGS=-D_BSD_SOURCE? It seems to me that if a piece of source code relies on a particular standard, it is best to spell it out explicitly in the code itself with a #define. However, a lot of…
William Pursell
  • 204,365
  • 48
  • 270
  • 300
6
votes
1 answer

Is Ahead-Of-Time compilation available in Java 9?

As per JEP 295 AOT compilation of any JDK modules, classes, or of user code, is experimental and not supported in JDK 9. To use the AOTed java.base module, the user will have to compile the module and copy the resulting AOT library into the JDK…
Mohit Tyagi
  • 2,788
  • 4
  • 17
  • 29
6
votes
2 answers

How to rebuild all Debian packages of a system with specific flag?

I would like to rebuild/recompile all Debian packages of a machine with specific flags. How can I do that with less command as possible? I have found that https://debian-administration.org/article/20/Rebuilding_Debian_packages but it does not…
aurelien
  • 404
  • 4
  • 22
6
votes
1 answer

Intellij - set default output path to gradle output

So, I created a new gradle project, choosing Java as "additional libraries and frameworks". Gradle will compile to .\build\classes and maintain package structure, but the "module compile output path" in project structure -> modules is set to…
User1291
  • 7,664
  • 8
  • 51
  • 108
6
votes
2 answers

If a compiler's back-end is the same for many programming language front-ends, will compiled object code is the same for different languages?

I know that compiler can have many front-ends. Each front-end translates the code written in a programming language to an internal data structure. Then inside that data structure the compiler makes some optimizations. Then the BACK-END of the…
user8613421
6
votes
2 answers

Can I create single file executable with nuitka?

As title says, can I create single file executable with nuitka? I tried --portable and --standalone option but they does not seem to work. And can anyone please explain me what is the --recurse-all option? And if you have some other recommendations…
Jakub Bláha
  • 1,491
  • 5
  • 22
  • 43
6
votes
2 answers

Why can't I pass template parameters on to another template?

Okay I'm going to give a simple example of my problem: void Increment(Tuple& tuple) { ++tuple.Get<0>(); } int main() { Tuple tuple; tuple.Get<0>() = 8; Increment(tuple); printf("%i\n", tuple.Get<0>()); //…
nonoitall
  • 1,232
  • 1
  • 15
  • 25
6
votes
3 answers

In the MinGW compiler, what is the -mwindows command, and what does it do?

I was having an issue with a C++ program where when I ran the .exe the program would run and my window for the program would open, but the console would be open on the desktop in the background. I did a google search and found that compiling with…
Kalcifer
  • 1,211
  • 12
  • 18
6
votes
4 answers

Compiling Qt - Visual Studio 2010

I am looking for any tutorials or information on compiling Qt 4.7 with Visual Studio 2010. I've recently have run into an bug using Qt 4.7.1 libraries on Visual Studio 2010 and have found information that recompiling Qt with 2010 can potentially…
cweston
  • 11,297
  • 19
  • 82
  • 107
6
votes
2 answers

libopencv_imgcodecs.so.3.2: cannot open shared object file: No such file or directory

I know that a similar question has been asked before, but none of the suggestions have helped. I am trying to compile an OpenCV project using C++ in Ubuntu 15.10. I can run the project correctly in Netbeans. But I am supposed to send this to…
Inquisitor
  • 61
  • 1
  • 1
  • 3
6
votes
2 answers

PHP 7.1.2 compilation and libcurl error

PHP 7.1.2 is here, i tried to compile it as usually but this time ./configure fail with these error: checking for cURL in default path... not found configure: error: Please reinstall the libcurl distribution - easy.h should be in…
krazitchek
  • 228
  • 3
  • 10
6
votes
1 answer

Conditional compilation in gfortran

I want to know if it is possible to select different parts of my Fortran 95 routine to compile. For example, if I pass certain flag to gfortran, then the compiler chooses which section to use for a certain function. I know I can do it using if…
Nando
  • 170
  • 3
  • 9
1 2 3
99
100