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).

15850 questions
5
votes
1 answer

Statically linking against LAPACK

I'm attempting to do a release of some software and am currently working through a script for the build process. I'm stuck on something I never thought I would be, statically linking LAPACK on x86_64 linux. During configuration…
nlucaroni
  • 45,818
  • 5
  • 58
  • 85
5
votes
1 answer

Compiled Class in Two Locations

I'm a tad stuck trying to get a List to load from the ViewState using ASP.NET 4 and VB.NET. When I try to retrieve a collection using: Public Property ItemsForImport As List(Of ImportItem) Get Return IIf(ViewState("ItemsForImport") Is…
Echilon
  • 9,631
  • 27
  • 126
  • 209
5
votes
1 answer

f# slow compilation

Is there anything I can do to make f# code compile faster apart from (or better yet instead of) running ngen? And what is approximate benchmark "hello world" compilation time (or better said compiler startup time+compilation time) for say pentium 4…
ren
  • 3,501
  • 7
  • 44
  • 88
5
votes
1 answer

How can I run java code that has been pasted into my program

I'm making a simulator for Time Complexity. The purpose is that Students can choose which algorithms they want to compare. But I want to make it possible to compare algorithms they've written themselves. I know how to get it to work with a compiled…
tgoossens
  • 8,946
  • 1
  • 13
  • 20
5
votes
2 answers

Compiling java from python

I'm writing a script to compile a .java file from within python But the error import subprocess def compile_java(java_file): cmd = 'javac ' + java_file proc = subprocess.Popen(cmd, shell=True) compile_java("Test.java") Error: javac is…
tgoossens
  • 8,946
  • 1
  • 13
  • 20
5
votes
2 answers

How can this linear solver be linked within Mathematica?

Here is a good linear solver named GotoBLAS. It is available for download and runs on most computing platforms. My question is, is there an easy way to link this solver with the Mathematica kernel, so that we can call it like LinearSolve? One thing…
5
votes
1 answer

OpenCL, include files

Following the post , if I have header file,which has some functions implementations in it and should be included in several kernels(I mean these function are auxilary in all kernels and I don`t want to duplicate the code) How I make this inclusion -…
Yakov
  • 8,699
  • 25
  • 100
  • 182
5
votes
1 answer

Assembly cannot find referenced assembly when compiled to memory with CodeDomProvider

i am trying to compile some code to memory at runtime using a CodeDomProvider. The code I am compiling have a reference to an external assembly which I include in the parameters used when compiling the code. When I compile to memory and try to use…
MartinF
  • 5,721
  • 5
  • 38
  • 28
5
votes
3 answers

"Cannot find symbol" error - even on a ridiculously simple example

So I've been trying to solve this problem for a matter of hours now. I've scoured the internet, I've scoured StackOverflow, I've asked some co-workers (I'm an intern) and honestly no one can tell me what is going on! I put together a really really…
Dave Anderson
  • 695
  • 3
  • 9
  • 17
5
votes
3 answers

Maven: Compiling package-info.java to package-info.class?

I have package-info.java in my package, Hibernate wants it for some features (programatic entity scanning). However, mvn package does not result in package-info.class being in classes/ thus not in the artifact. How can I force that happening? mvn…
Ondra Žižka
  • 36,997
  • 35
  • 184
  • 250
5
votes
0 answers

Compiling C/C++ application using SDL in OS X, linking problem

I'm trying to compile a C/C++ program that uses SDL on a OS X 10.6.8 but I'm having some errors on the linking stage, the code compiles but fails to like due to some missing symbols. The error is: Undefined symbols for architecture…
Sérgio
  • 203
  • 2
  • 11
5
votes
3 answers

Problems Compiling PHP with SSH2 pecl extension for Windows

First, I am not a programmer. I am a Network Admin who has been asked to compile PHP for our web designer with SSH2 enabled. I have been following this walk-through to compile PHP for…
pat_micro
  • 51
  • 1
  • 2
5
votes
3 answers

Why does Java generics type inference break in chained method calls?

Looking at the type inference for generic types in the following example, I cannot say why methodAutoTypeInference works fine, but methodNotCompilable (which is almost the same) fails to compile and to manage it the compiler requires additional…
diziaq
  • 4,203
  • 12
  • 38
  • 55
5
votes
1 answer

does statically compiling php pecl extensions (inside binary vs. extension=ext.so) improve performance?

does compiling pecl extensions inside the php binary improve performance? i hope my terminology is right, but: http://php.net/manual/en/install.pecl.static.php thats what i mean. we have a small set of extensions that are used in pretty much every…
anonymous-one
  • 12,434
  • 18
  • 52
  • 80
5
votes
0 answers

Unexpected symbols resolution when linking against c++ library

I'm building a library "libsimplemath.a", based on two objects (add.o and sub.o). The main only depends on add.o interface. When the code is linked against libsimplemath.a I would expect it works. It was the case up to the point I decide to switch…
Romain B
  • 51
  • 3
1 2 3
99
100