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
51
votes
3 answers

R CMD check note: Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’

How to avoid the following NOTE that is appearing in R CMD check with the new R development version ( R Under development (unstable) (2017-02-15 r72179))? • checking for unstated dependencies in examples ... OK • checking line endings in…
Crops
  • 5,024
  • 5
  • 38
  • 65
51
votes
2 answers

Difference between compiled and interpreted languages?

What are the relative strengths and weaknesses of compiled and interpreted languages?
51
votes
3 answers

Best practices for debugging linking errors

When building projects in C++, I've found debugging linking errors to be tricky, especially when picking up other people's code. What strategies do people use for debugging and fixing linking errors?
tsellon
  • 2,396
  • 5
  • 24
  • 33
51
votes
2 answers

The POM for project is missing, no dependency information available

Background Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added: mvn install:install-file \ -DgroupId=net.sourceforge.ant4x \ …
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
51
votes
4 answers

Compile the Python interpreter statically?

I'm building a special-purpose embedded Python interpreter and want to avoid having dependencies on dynamic libraries so I want to compile the interpreter with static libraries instead (e.g. libc.a not libc.so). I would also like to statically link…
Jeremy Cowles
  • 1,171
  • 1
  • 9
  • 13
50
votes
11 answers

Xcode/Swift 'filename used twice' build error

I'm new to Swift and am struggling with an error after I have (possibly) correctly installed a 3rd party framework via CocoaPods. The error is as follows. :0: error: filename "MainController.swift" used twice:…
RobertyBob
  • 803
  • 1
  • 8
  • 20
49
votes
4 answers

Elegantly call C++ from C

We develop some project in plain C (C99). But, we have one library as source codes (math library) in C++. We need this library so I would like to ask, what is the most elegant way to integrate this source codes? Ratio between sizes of C and C++ is…
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
49
votes
2 answers

How do you dynamically compile and load external java classes?

(This question is similar to many questions I have seen but most are not specific enough for what I am doing) Background: The purpose of my program is to make it easy for people who use my program to make custom "plugins" so to speak, then compile…
Shadowtrot
  • 710
  • 1
  • 7
  • 13
48
votes
4 answers

Empty function macros

If I define a function macro with no actual body, is it like an empty string with the compiler (i.e. It doesn't generate any extra instructions at compile time)? Example: #define SomeMacro(a) SomeMacro("hello"); // This line doesn't add any…
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
48
votes
4 answers

Can Razor views be compiled?

I was wondering if Razor views could be compiled, like WebForm based views? Does it even make sense to compile Razor views and why would somebody want to do that?
Khalid Abuhakmeh
  • 10,709
  • 10
  • 52
  • 75
48
votes
7 answers

How to parse html to React component?

This is my senario : 1. Application request CMS(Content management system) for page contents. 2. CMS return "
Hi,My Button
" 3. Application consume the content, render corresponding component with…
Sing
  • 3,942
  • 3
  • 29
  • 40
48
votes
3 answers

"Launch Configuration" Shows up Blank When Trying to Export Runnable Jar?

I've gotten this to work in the past, but now whenever I choose File > Export... > Runnable JAR File and select the drop-down menu "Launch Configuration", all I get is a blank bar. How can I get my main class to show up?
Justian Meyer
  • 3,623
  • 9
  • 35
  • 53
48
votes
2 answers

Skipping Incompatible Libraries at compile

When I try to compile a copy of my project on my local machine, I get an error stating that it 's skipping over incompatible libraries. This isn't the case when I'm messing around with the live version hosted on the server at work [it makes…
kelly.dunn
  • 1,546
  • 3
  • 16
  • 23
47
votes
7 answers

C/C++ header and implementation files: How do they work?

How does the main function know about function definitions (implementations) in a different file? For example, say I have 3 files: //main.cpp #include "myfunction.hpp" int main() { int A = myfunction( 12 ); ... } //myfunction.cpp #include…
nickelpro
  • 2,537
  • 1
  • 19
  • 25
47
votes
4 answers

parameter name omitted, C++ vs C

In C++, I tend to omit the parameter's name under some circumstances. But in C, I got an error when I omitted the parameter's name. Here is the code: void foo(int); //forward-decl, it's OK to omit the parameter's name, in both C++ and C int…
Alcott
  • 17,905
  • 32
  • 116
  • 173