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
130
votes
2 answers

C++ compile error: has initializer but incomplete type

I am coding in Eclipse and have something like the following: #include #include void read_file(){ char buffer[1025]; std::istringstream iss(buffer); } However, when I try to build, I get the following error: variable…
ElectronAnt
  • 2,115
  • 7
  • 22
  • 39
129
votes
12 answers

javac : command not found

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac. Do I need to install any other package? I have tried to locate the javac executable but i am unable to locate…
Bikash Barman
  • 1,309
  • 2
  • 9
  • 4
129
votes
6 answers

What is the difference between compile code and executable code?

I always use the terms compile and build interchangeably. What exactly do these terms stand for?
Lazer
  • 90,700
  • 113
  • 281
  • 364
126
votes
12 answers

How to watch and compile all TypeScript sources?

I'm trying to convert a pet project to TypeScript and don't seem to be able to use the tsc utility to watch and compile my files. The help says I should use the -w switch, but it looks like it can't watch and compile all *.ts files in the some…
VoY
  • 5,479
  • 2
  • 37
  • 45
121
votes
4 answers

What is the difference between "Include Directories" and "Additional Include Directories"

In configuration properties of my project, under the "VC++ directories" there is an entry for "Include Directories". But under "C/C++" option, there is another entry called "Additional Include Directories". Same thing happens with library…
Artium
  • 5,147
  • 8
  • 39
  • 60
119
votes
5 answers

Why doesn't the JVM cache JIT compiled code?

The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times. The question is, why isn't this compiled code cached to disk for…
Chinmay Kanchi
  • 62,729
  • 22
  • 87
  • 114
118
votes
20 answers

The project cannot be built until the build path errors are resolved.

While compiling an android project in eclipse 3.4.2, I am getting The project cannot be built until the build path errors are resolved. I got a temporary solution from the blog http://www.scottdstrader.com/blog/ether_archives/000921.html The…
yokks
  • 5,683
  • 9
  • 41
  • 48
117
votes
2 answers

How to check if program was compiled with debug symbols?

I'd like to trace some code in GIMP and therefore need GIMP with debug symbols enabled. I don't remember whether I have enabled them during compilation. How to check that without recompiling the program?
Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65
113
votes
8 answers

#ifdef #ifndef in Java

I doubt if there is a way to make compile-time conditions in Java like #ifdef #ifndef in C++. My problem is that have an algorithm written in Java, and I have different running time improves to that algorithm. So I want to measure how much time I…
jutky
  • 3,895
  • 6
  • 31
  • 45
112
votes
14 answers

What is the difference between a token and a lexeme?

In Compiler Construction by Aho Ullman and Sethi, it is given that the input string of characters of the source program are divided into sequence of characters that have a logical meaning, and are known as tokens and lexemes are sequences that make…
user1707873
  • 1,307
  • 2
  • 10
  • 10
111
votes
5 answers

How do I compile and run a program in Java on my Mac?

How do I compile and run a program in Java on my mac? I'm new. Also I downloaded a program that was suggested to me on here called text wrangler if that has any bearing on the situation.
David
  • 14,569
  • 34
  • 78
  • 107
109
votes
6 answers

How to keep up with the latest versions of Node.js in Ubuntu? PPA? Compiling?

Where can (can I ?) find .deb packages for the latest versions of Node.js ? If not, and because it's a project that progresses very fast, what is the easiest way to keep up with the releases of Node.js ? Adding some PPA and it will be updated when…
João Pinto Jerónimo
  • 9,586
  • 15
  • 62
  • 86
102
votes
9 answers

iOS Build Failed at compile time with issue "failed to find a suitable device for the type SimDeviceType"

I am getting following compile time issue when running the app with Xcode 10.3 beta 2 on iPad Air, I am getting the below issue. Failed to find a suitable device for the type SimDeviceType : com.apple.dt.Xcode.IBSimDeviceType.iPad-2x with runtime…
Rein rPavi
  • 3,368
  • 4
  • 22
  • 32
102
votes
8 answers

Java compile speed vs Scala compile speed

I've been programming in Scala for a while and I like it but one thing I'm annoyed by is the time it takes to compile programs. It's seems like a small thing but with Java I could make small changes to my program, click the run button in netbeans,…
user405163
  • 1,205
  • 2
  • 10
  • 10
101
votes
6 answers

Are GCC and Clang parsers really handwritten?

It seems that GCC and LLVM-Clang are using handwritten recursive descent parsers, and not machine generated, Bison-Flex based, bottom up parsing. Could someone here please confirm that this is the case? And if so, why do mainstream compiler…
JCLL
  • 5,379
  • 5
  • 44
  • 64