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
26
votes
6 answers

Compiling a .vbproj or .csproj project file without Visual Studio

Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does? When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like: vbc.exe [bunch of options]…
Daniel Magliola
  • 30,898
  • 61
  • 164
  • 243
26
votes
5 answers

How to run prolog code?

I am working on family tree in prolog. I don't have any idea how to compile and run this program. Please give me some basic steps to run it.
Subodh Mankar
  • 365
  • 2
  • 6
  • 13
26
votes
2 answers

Erlang compilation - Erlang as stand alone executeable

is there a way to compile Erlang to be a stand-alone executable? this means, to run it as an exe without the Erlang runtime.
qwerty
  • 261
  • 3
  • 3
26
votes
2 answers

How do I compile a .cpp file just to object file without calling linker

I am trying to compile a single .cpp file separately from the build process. If I do a full build then the compile step outputs to the directory configured when creating the project. However if I just ask for a compile I end up with the object file…
Peter Nimmo
  • 1,045
  • 2
  • 12
  • 25
26
votes
4 answers

Undefined reference to `initscr' Ncurses

I'm trying to compile my project and I use the lib ncurse. And I've got some errors when compiler links files. Here is my flags line in Makefile: -W -Wall -Werror -Wextra -lncurses I've included ncurses.h Some layouts : prompt$> dpkg -S…
BoilingLime
  • 2,207
  • 3
  • 22
  • 37
26
votes
5 answers

Speed up compile time with SSD

I want to try to speed up my compile-time of our C++ projects. They have about 3M lines of code. Of course, I don't need to always compile every project, but sometimes there are lot of source files modified by others, and I need to recompile all of…
Jamby
  • 1,886
  • 2
  • 20
  • 30
26
votes
4 answers

Java "new String[-1]" passes compilation. How come?

While fiddling around in Java, I initialized a new String array with a negative length. i.e. - String[] arr = new String[-1]; To my surprise, the compiler didn't complain about it. Googling didn't bring up any relevant answers. Can anyone shed…
Tom Teman
  • 1,975
  • 3
  • 28
  • 43
25
votes
5 answers

How to run ruby programs on Windows 7?

Does anyone know how to run/compile Ruby programs on Windows 7? For example you can compile Java in Eclipse, but I can't seem to find one for Ruby.
Daniel Cook
  • 1,856
  • 8
  • 23
  • 28
25
votes
8 answers

vim compiles with wrong python version (and not working with needed version)

In brief: I have a problem with compiling vim with preferred python version. When I use --enable-pythoninterp it compiles with system OSX python version. When I use --enable-pythoninterp=dynamic I get an error in vim while trying :py import sys Here…
oluckyman
  • 3,566
  • 3
  • 28
  • 35
25
votes
1 answer

Using latest JavaScript features in TypeScript, such as ES2018

I have tried searching through TypeScripts documentation on their configurtion and can't seem to find the answer to what should be a simple question. Simply, how does one configure the typescript compiler so that it knows what JavaScript feature…
ste2425
  • 4,656
  • 2
  • 22
  • 37
25
votes
4 answers

How to change the amount of building threads in Xcode?

I'm building a couple of C++ files in xcode that take a lot of memory to compile (+1 GB / file). Because I do this on my dual core laptop, xcode uses 2 threads for building. The two threads will eventually be building the files that take a lot of…
Dries Staelens
  • 351
  • 1
  • 3
  • 7
25
votes
6 answers

Does C# support if codeblocks without braces?

How would C# compile this? if (info == 8) info = 4; otherStuff(); Would it include subsequent lines in the codeblock? if (info == 8) { info = 4; otherStuff(); } Or would it take only the next line? if (info == 8) { info =…
Kevin Boyd
  • 12,121
  • 28
  • 86
  • 128
25
votes
12 answers

Error while loading shared libraries: /usr/local/lib64/libssl.so.1.1

I’m trying to compile openssl-1.1.0e on Centos 7 (7.3.1611) but after i successfully compiled everything without any warning, i get an error when i’m trying any openssl command [mdm@dev openssl-1.1.0e]$ openssl version openssl: error while loading…
fromthestone
  • 1,217
  • 2
  • 13
  • 16
25
votes
10 answers

Scala Compiliation error with intellij

I'm trying to compile a mixed java-scala code using intelliJ 14.1.4 but it keeps giving me this error: Error Compiling SBT component 'compiler-interface-2.9.2-52.0' I have tried to down grade my scala-compiler version but this didn't helped. any…
vlady
  • 477
  • 1
  • 7
  • 14
25
votes
2 answers

Using emoji as identifier names in C++ in Visual Studio or GCC

Traditionally, the accepted characters we can use as part of an identifier in C++ are _, a-z, A-Z and 0-9 after the first character. Is there a way to configure Visual Studio or GCC to accept emoji as part of the identifier names (or any other…
ButterDog
  • 5,115
  • 6
  • 43
  • 61