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
1 answer

Multiple definition gets solved with templates

a.hpp: #pragma once struct S { static int v; }; int S::v = 0; b.hpp: #pragma once void addOne(); b.cpp: #include "b.hpp" #include "a.hpp" void addOne() { S::v += 1; } main.cpp: #include #include "a.hpp" #include "b.hpp" int…
Darius Duesentrieb
  • 837
  • 10
  • 20
6
votes
1 answer

Angular: ngc or tsc?

I have been using tsc, but see that angular.io emphasizes ngc. I am wondering if there are advantages to either or if I should choose one over the other. Thanks in advance.
David Streid
  • 685
  • 3
  • 12
  • 24
6
votes
1 answer

C++: templated inherited recursive classes: impossible triple-threat?

So, say you have a base class which is recursive (e.g. a linked list) and a derived class as well. The derived class should reuse the constructor from the base class, because you don't want to write redundant code. You could try the obvious thing,…
user511493
  • 263
  • 1
  • 2
  • 7
6
votes
1 answer

How to compile fontconfig without uuid

I want create fontconfig's dylib but I have to do that without uuid Mine ./configure options are: ./configure --disable-docs --disable-dependency-tracking --disable-silent-rules --enable-shared…
Martin
  • 93
  • 7
6
votes
1 answer

Creating a python script to compile and run a c++ file

I have been writing a simple python script to compile and run a given .cpp file. I've gotten it to work as expected but I want to be able to stop the script if the compilation of the .cpp file produces errors or warnings, rather then going on to…
karanveer41
  • 221
  • 1
  • 2
  • 6
6
votes
1 answer

What is the process gone through during Objective-C compilation

I'm currently having some linker problems when trying to compile an Objective-C program and think that the reason why I can't figure out the issue may be due to ignorance as to the compiler process. Would it be possible for somebody to give me an…
Danny
  • 557
  • 5
  • 16
6
votes
5 answers

Compile for 32 bit or 64 bit

I'm writing an app, and I am wondering whether I should compile it in 32-bit mode or 64-bit mode. The program doesn't use any 64-bit types and doesn't access over 4 gigabytes of memory (and I don't plan on it ever accessing that much memory). The…
Cpp plus 1
  • 990
  • 8
  • 25
6
votes
1 answer

How are you supposed to know what library names are

When using a tool like pkg-config (see here), how is one supposed to know what the library name should be? It is not always intuitive. DLIB, for example, doesn't work for pkg-config --cflags dlib pkg-config --cflags libdlib pkg-config --cflags…
puk
  • 16,318
  • 29
  • 119
  • 199
6
votes
1 answer

Specify build verbosity for command line build using devenv

Is there a way to specify build verbosity for command line build using devenv? I'm trying to make a test that builds our solution twice and the second time it builds it should output: Build: 55 succeeded, 0 failed, 69 up-to-date, 1 skipped But it…
Derek
  • 7,615
  • 5
  • 33
  • 58
6
votes
5 answers

What's c++ compiling performance bottle neck?

When I do a fresh compilation for my project, which includes 10+ open-source libs. It takes about 40mins. (on normal hardware) Question: where really are my bottle necks at? hard-drive seeking or CPU Ghz? I don't think multi-core would help much…
c2h2
  • 11,911
  • 13
  • 48
  • 60
6
votes
2 answers

Usage and performance of com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize

We came across a JaxB class loading issue as highlighted by Jaxb classCastException. To fix that I added com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true and that actually FIXED the issue. However, I read that this will disable Jaxb's…
Ashish Thukral
  • 1,445
  • 1
  • 16
  • 26
6
votes
1 answer

Build entire solution but add global Conditional Compilation Symbols for just one project

I hava a quite complex solution, containing 10 projects aside from Test projects. It is a network of distributed applications & services that communicate using remoting; therefore having the proper referenced assemblies (& versions) is crucial.…
user588939
  • 61
  • 1
  • 2
6
votes
2 answers

SBCL: building a standalone executable

How do I build a standalone executable in SBCL? I've tried ; SLIME 2.20 CL-USER> (defun hullo () (format t "hullo")) HULLO CL-USER> (sb-ext:save-lisp-and-die "hullo" :toplevel #'hullo :executable t) but that just produces the…
Toothrot
  • 334
  • 2
  • 10
6
votes
3 answers

VB6 compilation from command line

Anyone knows how to compile a vb6 webclass dll from a command line? I am trying to build a tool for automating version building, but it fails with an 'Compile Error in File '[file name]', Line xxxx : Variable not defined' alert displayed.
Michal Dymel
  • 4,312
  • 3
  • 23
  • 32
6
votes
0 answers

How to compile or deploy a Haskell executable to Windows

I have a simple, self contained, open source Haskell app that compiles on a Windows system with cabal build. Let's assume it uses one or two nontrivial C libraries, such as OpenGL. I develop on Linux, with no access to a Windows machine. Question:…
Turion
  • 5,684
  • 4
  • 26
  • 42