Linking a C++ 64-bit Windows Hello World Application

From RAD Studio
Jump to: navigation, search

Go Up to Using ILINK32 and ILINK64 on the Command Line

Application code

 
//hello.cpp 
#include<iostream> 
#include<string> 
int main(int, char**) 
{ 
  std::string s("Hello world"); 
  std::cout<<s; 
  return 0; 
}

Compiling

You can compile this source using:

> "C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\bcc64.exe" -cc1 -D _RTLDLL -isystem "C:\Program Files (x86)\Embarcadero\Studio\20.0\include" -isystem "C:\Program Files (x86)\Embarcadero\Studio\20.0\include\dinkumware" -isystem "C:\Program Files (x86)\Embarcadero\Studio\20.0\include\windows\crtl" -fborland-extensions -triple=x86_64-pc-win32-elf -emit-obj -std=c++11 -o Hello.o Hello.cpp				

This command creates the Object(.0) file needed for linking.

Linking

Then link the .a and .o files, and create the 64-bit Windows executable file for the HelloWorld App using the following command:

> "C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\ilink64" -j"C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\win64\release" -Gn c0x64 Hello.o , Hello.exe , Hello.map , import64.a cw64mti.a , ,  

Now run Hello.exe, and "Hello world" prints on the screen.

See Also