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
86
votes
7 answers

Is there a way to compile node.js source files?

Is there a way to compile a node.js application?
Mark
  • 67,098
  • 47
  • 117
  • 162
86
votes
12 answers

Building Python with SSL support in non-standard location

I need to install several Python modules on a RHEL where I don't have root access. At least one of the modules also needs access to Python.h. In this case I find that the best thing is to install python and it dependencies in ~/local. It usually…
Matteo Caprari
  • 2,869
  • 4
  • 27
  • 35
83
votes
11 answers

How do I invoke a text editor from the terminal?

In the Windows command prompt, I can type notepad helloworld.cpp which will then create a .cpp file with the name helloworld and open up Notepad for me. Is there a similar function for Mac Terminal, preferably with Textmate or Textedit? I'm running…
Ceetang
  • 933
  • 1
  • 6
  • 7
82
votes
9 answers

What are the advantages of just-in-time compilation versus ahead-of-time compilation?

I've been thinking about it lately, and it seems to me that most advantages given to JIT compilation should more or less be attributed to the intermediate format instead, and that jitting in itself is not much of a good way to generate code. So…
zneak
  • 134,922
  • 42
  • 253
  • 328
82
votes
5 answers

How to get the list of options that Python was compiled with?

You can compile Python in various ways. I'd like to find out with which options my Python was compiled. Concrete use-case: was my Python compiled with readline? I know I can see this by doing "import readline", but I'd like to see a list of…
Niels Bom
  • 8,728
  • 11
  • 46
  • 62
81
votes
2 answers

How to fix fatal error: zlib.h: no such file or directory?

I'm trying to compile miniSAT on Kali Linux 64 bits but I keep getting the error message: fatal error: zlib.h: no such file or directory I have read that there might be a linking problem that makes the compiler unable to find the header files, but…
user3043108
  • 965
  • 1
  • 8
  • 10
81
votes
7 answers

Is it possible to compile a program written in Python?

I am new to the Python programming language. I was wondering if it is possible to compile a program to written in Python. Is it possible to convert Python scripts to some lower level programming languages which then can be compiled to binary code? A…
bjh Hans
  • 899
  • 1
  • 10
  • 10
80
votes
4 answers

Is there a limit to the number of nested 'for' loops?

Since everything has a limit, I was wondering if there is a limit to the number of nested for loops or as long as I have memory, I can add them, can the Visual Studio compiler create such a program? Of course a 64 or more nested for loops would be…
Fred Smith
  • 2,047
  • 3
  • 25
  • 36
80
votes
19 answers

Compiling and Running Java Code in Sublime Text 2

I am trying to compile and run Java code in Sublime Text 2. Don't just tell me to do it manually in the Command Prompt. Can anyone tell me how? Btw, I am on Windows 7...
tolluy
  • 919
  • 1
  • 7
  • 4
79
votes
2 answers

What is supercompilation?

Short and sweet: I've seen several sources talking about "supercompilation". But I have yet to find one single document anywhere on the face of the Internet which describes what this is. Presumably because it seems simple enough to whoever that it…
MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220
78
votes
13 answers

ARM compilation error, VFP registers used by executable, not object file

I have been having this problem for the last few days and I can't get my head around what is really happening here, or what is the problem. I have a makefile with these flags: CC = arm-linux-gnueabihf-gcc-4.6 FLAGS = -O3 -march=armv7-a…
Jim
  • 3,236
  • 8
  • 33
  • 43
78
votes
8 answers

Process to convert simple Python script into Windows executable

I wrote a script that will help a Windows user in her daily life. I want to simply send her the .exe and not ask her to install python, dlls or have to deal with any additional files. I've read plenty of the stackoverflow entries regarding compiling…
greye
  • 8,921
  • 12
  • 41
  • 46
78
votes
5 answers

Compilation error - missing zlib.h

I am trying to compile software on Blue Gene Q using IBM XL compilers and I got this error message: "iostreams/zlib.cpp", line 19.10: 1540-0836 (S) The #include file "zlib.h" is not found. make[3]: *** [zlib.o] Error 1 I have installed a new…
didymos
  • 1,191
  • 3
  • 10
  • 13
77
votes
6 answers

Why do I get compilation error "org/codehaus/groovy/control/CompilationFailedException"?

I am trying to compile my JasperReports template using an Ant script and Java. I am getting this error: jasper java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException There is nothing complex in the template, but I…
user726478
77
votes
5 answers

Unable to locate tools.jar

Possible Duplicate: Unable to locate tools.jar I'm trying to use ant to compile using this command : ant compile I don't know if the problem comes from my windows 64bit, or by something else. Because I have java Installed in the 64 & 32 prog…
Wassim AZIRAR
  • 10,823
  • 38
  • 121
  • 174