Testing the installation
To test the product installation and the critical search paths, build and run a sample application.
About this task
Procedure
- Create the following C program and name the
source file hello.c:
#include <stdio.h> int main(void) { printf("Hello World!\n"); return 0; }
- Compile
the program:
If you have set up the short invocation commands, enter the following command:
If you have not set up the short invocation commands, enter the following command:xlc hello.c -o hello
where installation_path is the installation location of the compiler packages. If the compiler has been installed to the default location, installation_path is /opt/ibm/.installation_path/xlC/13.1.4/bin/xlc hello.c -o hello
- Run the program by entering the following
command:
./hello
The result is "Hello World!".
- Check the exit
code of the program by entering the following
command:
echo $?
The result is "0".
- Create the following C++ program and name
the source file hello.cpp:
#include <iostream> using namespace std; int main() { cout << "Hello World!\n"; return 0; }
- Compile the program:
If you have set up the short invocation commands, enter the following command:
If you have not set up the short invocation commands, enter the following command:xlc++ hello.cpp -o hello
where installation_path is the installation location of the compiler packages. If the compiler has been installed to the default location, installation_path is /opt/ibm/.installation_path/xlC/13.1.4/bin/xlc++ hello.cpp -o hello
- Run the program :
./hello
The result should be "Hello World!".
- Check the exit code of the program:
echo $?
The result should be “0”.
Parent topic: After installing IBM XL C/C++ for Linux, V13.1.4