XL
C compiler
Hello everyone today i am going to discuss how to
compile and run C and C ++ program on AIX .Generally XL C/C++ compiler is
used for compiling C and C++ program on AIX platform.
While doing administration of AIX operating system one
day i got mail from application development team that they need to compile C
program on AIX, is there any way that we can compile on AIX.
After this i started googling and found that there is
XL C compiler for compiling and running C program on AIX operating system. Also
found that there is some evaluation version also available on IBM portal which I
can install for limited time(60 Day) and after evaluation time expire
,organization need to purchase new license version for XL C. I informed this
update to my manager and he suggested that for now install evaluation version
and also check with IBM agent for license version.
So from following link i downloaded XL C/C++ compiler
evaluation version and copied on required AIX LPAR. If your organization afford
to pay for license and need XL C/C++ for long term, they can go for license
version. In our case we first installed evaluation version, because of urgent
requirement.
Evaluation period for XL C C++ was 60 days.
You can download latest evaluation version from
following IBM Link.
"http://www.ibm.com/developerworks/downloads/r/xlcplusaix/"
And for downloading licensed version u need to contact
IBM and same licensed version admin can download from IBM "Entitled
Software Support". For downloading licensed product from IBM
Entitled Software Support your organization must have
login ID provided by IBM.
Let’s see how to install evaluation version on AIX .
I had copied XL C C++ compiler evaluation version on
/tmp/compiler directory.
**Before staring
installation i want to highlight below mentioned important thing .
keep ready AIX OS base CD/DVD
fileset,these fileset will help you when some pre-requisite failure occur
during installation of XL C compiler. In our case we wasted lot of time for
finding
pre-requisite fileset "xlsmp.rte".
Step 1.
Execute following command from AIX LPAR
smitty easy_install
Then chose . current directory where i stored files required
for installation.
Step 2:
Choose appropriate package according to AIX version, i
was configuring XL C/C++ on AIX 5.3 so i selected "vacpp-evaluation-aix53".
For
6.1 and 7.1 admin must choose "vacpp-evaluation-aix61-aix71".
Here
during installation of this evaluation version one query came in mind was, how I
going to upgrade or install licensed version after evaluation version will expired
??
Answer to this query is like , AIX admin first need to buy licensed version and
copy that files on AIX LPAR and choose following option while installing
using "smitty easy_install".
1.licensed version on AIX V5.3, choose
vacpp-licensed-aix53
For installing licensed version on AIX V6.1 or V7.1, choose
vacpp-licensed-aix61-aix71
Step 3 :
From same smitty
easy_install menu in step 1 select like following
AUTOMATICALLY install requisite software? Option
to
yes to install the compiler automatically
change the EXTEND file systems if space
needed? option to yes to
extend file systems
You must change the ACCEPT new license
agreements? option to yes to
accept new license agreements
Press enter and after successful installation check whether it successfully
installed or not.
also my suggestion is take preview of install before installing these fileset,
so that u will get idea that any requisite fileset is missing or
not.
Press ESC +0 to exit from Smitty menu.
After this installation i thought that it get installed and i informed
application team that i installed required fileset on server. But when they
tried to compile there C program using xlc command they getting error message
that "command not found". So after checking read me document of IBM
for XL C/C++ compiler found that i missed symlink creation for "xlc"
command and i need to set environment variable for specific user on AIX.
So i created following 2 symlink for xlc and xlc++.
1. xlc symlink to compile C program.
ln -s /usr/vacpp/bin/xlc
/usr/bin/xlc
2.xlc++ symlink to compile
C++ programm.
ln -s /usr/vacpp/bin/xlc++ /usr/bin/xlc++
Also we can add following entry in /etc/environment file
like below
Add /usr/vac/bin/ and /usr/vacpp/bin/ to
your PATH environment variable
To confirm whether soft link created or not you can confirm
by following command
#which xlc
/usr/bin/xlc
#which xlc++
/usr/bin/xlc++
From above output we can confirm that symlink successfully
created and environment properly set for running C and C++ code on AIX.
So let’s Test some C and C++ program.
test.c //sample c program
Create test.c on AIX LPAR and put following C code in test.c file.
#include
int main(void)
{
printf("Test program!\n");
return 0;
}
Compile C program using xlc
#xlc test.c -o test
Run program by executing below command.
#./test
Test program!
test1.cpp //sample C++ programm
create test1.cpp and copy following code in test1.cpp file.
#include
int main()
{
std::cout << "Test cpp programm!\n"
<< std::endl;
return 0;
}
Compile C++ program using
xlc++
#xlc++ test1.cpp -o test1
Run program
#./test1
Test cpp programm!
If
IBM XL C/C++ for AIX software evaluation
license expired?
there is work around suggested by IBM like below
Workaround:
AIX admin can add following entry in .profile file of
user for workaround.
Edit /etc/profile
and add following entry.
XLC_EXTEND_EVAL=yes
Also we can use export of environment variable "XLC_EXTEND_EVAL=yes"
# export XLC_EXTEND_EVAL=yes
This will extend XL
C/C++ to Total 74 days. Previous evaluation period was 60 days ,this workaround
will 14 more days.
So you must be thinking that what will
happened after evaluation version getting expired. Answer to this was, we
purchased licensed for XL C compiler and we did install/upgrade of XL C
compiler after evaluation time ended.
If during installation you face any difficulty you can refer Guide to install
XL C .
"http://www-01.ibm.com/support/docview.wss?uid=swg27024212&aid=1"
Thanks!!!!