AIX development environment Visual Age C ++ 6.0

xiaoxiao2021-03-06  56

As IBM PSeries server market share, the AIX operating system is also loved by more and more IT owners. AIX is an excellent member of the UNIX family. The latest version of AIX is AIX 5L version 2. The most common version is 4.3.3. Take 5L version 2 as an example. The default installation directly supports J2EE, here It mainly introduces the C / C development section of the AIX system.

It should be clear that AIX does not integrate C / C . To use this part of the function, you must install IBM C or Visual Age C (including C compiler), this article only introduces Visual Age C , will be installed in Visual Age C , Configuration, the compiler, the order of program debugging, the platform used is AIX 5L.

Install Visual Age C

Visual Age C To use on AIX 5L, the lowest version is 5.0.2, and now the latest version is 6.0. Visual Age C is a powerful integrated development environment, like Visual C of the Windows platform, provides a range of perfect graphical operation interfaces from the management, editing, compiling, commissioning, etc. of the project. To fully install (including the IDE graphical interface) Visual Age C , follow these steps:

1) Determine the MOTIF file set required for the IDE graphical interface already installed, the command is as follows:

Lslpp -l x11.compat.adt.motif12

If not installed, you should install this fileset from the AIX operating system installation media.

2) Put the Visual Age C installation medium into the drive of the machine

Note that if it is a Visual Age C product disk, do not need a Mount CD disk

3) Start installing the Visual Age C file set, the command is as follows:

Smitty install_latest

Install the directory Select an optical zone, use the F4 key to choose, as follows,

If you need to select the installation section file set, press the F4 key under the _all_latest menu item,

Use the F7 key to select the file set you want to install, press Enter key.

What is introduced above is a complete installation method. If you just use the C / C compiler, you don't want to install the Visual Age C graphical interface, you can use the following command:

Installp -Axgd / dev / cd0 vacpp.cmp

The result of this command is to install all the files we need.

If the installation medium used is not a disc, it is a mounting medium such as Vacpp6.tar.z. The following method can be used for installation.

The Vacpp6.tar.z is uploaded to the target server server. You can then select the installation directory.

We choose to upload Vacpp6.tar.z to the / Home directory of the target server, and use the uncompress command to decompress. Then establish a temporary directory under / home. We named VAC, (MKDIR VAC).

Perform tar -xf ../vacpp6.tar commands under / home / vac.

Finally, execute SmitTallp under /Home/vac/usr/sys/inst.images / installation.

Configure Visual Age C

After installation of Visual Age C , you can't use it immediately, you need to configure the license to use it correctly. The use of Visual Age C is managed by the LUM (License Use Management) system, so the correct configuration method is to configure the LUM, and then configure the license of Visual Age C . Step 1: Configure LUM

The LUM is a must-have component in the AIX 4.3.3 and 5L versions. It is already installed during the initial installation of the system, but does not configure, configure the i4cfg command, as follows:

#CD / USR / OPT / IFOR / BIN

#. / i4cfg -script

This command will configure the Concurrent NodeLock Server if there is no error output, and the next step is to start the LUM server:

#. / i4cfg -start

After that, you can detect the working status of the LUM server with the following command:

#. / i4cfg -list

Step 2: Configure the license of Visual Age C

After proper installation, you can see the suffix for libly file in / usr / VAC and / usr / vacpp, which records the Visual Age C license agreement, which needs to be added to add the required license agreement to LUM management. The command used is i4BLT, and the method is:

I4BLT -A -F license_file_name -r u -t license_num

The specific process is as follows:

First add C's license,

#CD / USR / OPT / IFOR / BIN

#. / i4blt -a -f /usr/vac/cforaix_cn.lic -r u -t 10

Then configure C license,

#. / i4blt -a -f /usr/vacpp/vacpp_cn.lic -r u -t 10

The number of licenses configured in the above example is 10, and the correct configuration can be verified whether the license number is correct or the protocol is not properly added.

I4blt -sl CN

Note that the above configuration is performed on the AIX 5L version, such as on the AIX version 4.3.3, I4CFG, the i4blt command exists / var / ifor / bin directory.

Visual Age C

After installation, configuration, you can use the C / C compiler, but when you run the CC, it is found that the CC is not found, do not doubt the correctness of the installation, this is no environmental variable, in / usr / vac / bin There is a script file replacecset in the directory, which will complete all.

You can use a most classic applet hello.c to test the correctness of the compiler, the program content is as follows:

#include

MAIN () {

Printf ("Hello! / N");

}

Compile, connection:

cc -o hello hello.c

The Hello executable will be generated.

In general, our habits directly use the CC compilation program. In fact, the AIX's C / C compiler also provides some other ways, such as XLC_R, XLC_R, which is _r, here we do a complete introduction.

The default C compiler on the AIX platform is XLC, and the C's compiler has three:

CC: This is the most habitually used, extended mode C compiler

XLC: ANSI C compiler, using UNIX header C89: ANSI C compiler, using ansi header file

For details, what compiler is selected, and it is necessary to select according to the situation of the program, usually we can use CC. In addition, there are some suffixes for us to choose, combined with the basic compilers, give us a larger selection surface, as follows:

_r connection UNIX98 standard thread library _R4 connection POSIX DRAFT4 (DCE) Standard thread library _r7 Connection POSIX DRAFT7 Standard Unit Library 128 DOUBLE Type 128 bits and use connection-related libraries 128_r Double types 128 bits and use UNIX98 thread library 128_r4 Double type 128 is to use the connection POSIX DRAFT4 thread library 128_r7 double Double type 128 bits and use the connection POSIX DRAFT7 thread library

In addition, UNIX98 is compatible with the content of UNIX95, POSIX standard, so if the thread function is used in the program, it can increase the suffix _r. For example, compiling ANSI C and use the POSIX thread library, you can use the XLC_R compiler, of course, the form of xlc -lpthread can be used.

It is only the most basic things mentioned here, and there are many aspects of content, such as how to generate dynamic libraries, these more detailed things need to be referred to related manuals, or call IBM technical support to seek technical support.

Program debugging

The debugging program is more complicated. On the one hand, we need some debugging tools, such as DBX, Truss, TPROF, etc., and on the other hand, we also need some debugging experience.

Here is a method of using DBX debugging operations, focusing on debugging steps, not in the use of DBX tools, as an example of a simple program, program:

#include

MAIN () {

Long count = 0;

Int loop_count;

While (1) {

Count * = (count );

Printf ("Test Debug, Count: LD / N", Count);

For (loop_count = 0; loop_count <10; loop_count ) {

Sleep (1);

}

}

}

Program name DBG.C

The debugging steps are as follows:

1) Compile DBG.C

XLC -G -O DBG DBG.C

2) Run the DGB program

./dbg

3) View the process ID of the DBG program

PS-EF | GREP DBG | GREP -V GREP

Suppose DBG's PID is 12345

4) Debug DBG program

DBX -A 12345

5) At this time we run the DBX command debug DBG program, the following is a few common commands:

STEP: Single step run

Stop at line_number: Set breakpoints in a row

STOP in subroutine_name: Set the breakpoint to a function

Cont: Continue to run

6) Exit debugging

Note that DETACH should be used instead of exit when exiting, otherwise it will affect the operation of the program, causing the program to exit.

This article is just a brief introduction to the development environment of AIX. The content used in actual work will be far more than this knowledge.

http://www-900.ibm.com/developerWorks/cn/index.shtml

转载请注明原文地址:https://www.9cbs.com/read-114835.html

New Post(0)