A simple Hello World application can demonstrate some of the debugger's basic features.
Create a new file named helloworld.c in a working directory. Add the following code to helloworld.c:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
The Intel Debugger does not support position independent executable (pie).
On some systems the compiler option -fpie is set by default. Use -fno-pie to disable pie.
Before compiling you must set the environment variables as described in the Intel® Compiler User Guide.
Compile the application:
On Linux* OS, compile the application using the following command:
icc -debug -O0 helloworld.c -o helloworld
On OS X*, the debugger reads debug information from object files. As a result, the executables do not contain any debug information. To be able to debug, you must retain the object files.
First, create an object file with debug information using the following command:
icc -debug -O0 –c helloworld.c -o helloworld.o
Then compile the application using the following command:
icc -debug -O0 helloworld.o -o helloworld
Following successful compilation, the compiler creates an executable named helloworld in the working directory.
Create a new file named helloworld.f90 in a working directory. Add the following code to helloworld.f90:
program main print *,"Hello World!" end program main
Open a shell and change to the working directory.
Compile the application:
On Linux* OS, compile the application using the following command:
ifort -debug -O0 helloworld.f90 -o helloworld
On OS X*, the debugger reads debug information from object files. As a result, the executables do not contain any debug information. To be able to debug, you must retain the object files.
First, create an object file with debug information using the following command:
ifort -debug -O0 –c helloworld.f90 -o helloworld.o
Then compile the application using the following command:
ifort -debug -O0 helloworld.o -o helloworld
Following successful compilation, the compiler creates an executable named helloworld in the working directory.