Linking a C++ Hello World Application for macOS

From RAD Studio
Jump to: navigation, search

Go Up to XLINK.EXE, the macOS Linker

ILinkOSX.exe links the .a and .o files into a macOS application. Executable Mac app files typically have no file extension.

Application code

int main(int, char**) 
  std::string s("Hello world"); 
  return 0; 


You can compile this source using:

> bccosx -c hello.cpp

You can alternatively remove the -c option and let the compiler invoke the linker if possible. This way the compiler can determine the correct library paths and set the linker options as appropriate.


Then link the .a and .o files into the App using the following command:

> xlink.exe hello.o start.o,hello,,libSystem.dylib libcgrtl.a libcgstl.a libcgunwind.1.0.dylib,, 

Now run the hello app, and you will see "Hello world" print on the screen.


See Also