1.5 "Hello world" example

This example shows how to build a simple C program hello_world.c with armclang and armlink.

Procedure

  1. Create a C file hello_world.c with the following content:
    #include <stdio.h>
    
    int main()
    {
        printf("Hello World\n");
        return 0;
    }
  2. Compile the C file hello_world.c with the following command:
    armclang --target=aarch64-arm-none-eabi -march=armv8-a -c hello_world.c

    The -c option tells the compiler to perform the compilation step only. The -march=armv8-a option tells the compiler to target the ARMv8-A architecture, and --target=aarch64-arm-none-eabi targets AArch64 state.

    The compiler creates an object file hello_world.o

  3. Link the file:
    armlink -o hello_world.axf hello_world.o 
    

    The -o option tells the linker to name the output image hello_world.axf, rather than using the default image name __image.axf.

  4. Use a DWARF 4 compatible debugger to load and run the image.
    The compiler produces debug information that is compatible with the DWARF 4 standard.
Non-ConfidentialPDF file icon PDF versionARM 100066_0608_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.