3

I've got two Hello World programs, written in C++ and Rust:

main.cpp

#include <iostream>

using namespace std;

int main() {
    cout << "Hello World!" << endl;
}

main.rs

fn main() {
    println!("Hello World!");
}

I compiled both of them using these commands:

g++ main.cpp -o Test.bin

and

rustc main.rs -o Test-Rust.bin

Checking for the MIME-type of the C++ binary returned an executable, as I expected:

$ file --mime-type Test.bin 
Test.bin: application/x-executable

But the Rust binary appears to be a shared library:

$ file --mime-type Test-Rust.bin 
Test-Rust.bin: application/x-sharedlib

Why does the Rust compiler not output a plain application like g++ does?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
PEAR
  • 685
  • 3
  • 10
  • 20

0 Answers0