C ++ program from linux to aix5.3 -- general Linux technology-Linux programming and kernel information. The following is a detailed description. Since linux and win32 have been used for program development, the portability of the program only takes into account the two platforms. Later, the program needs to be transplanted to AIX5.3, at that time, we thought that AIX is also a UNIX-like system and should support the POSIX standard. There is no problem with porting. However, some problems have been found in practice, which are summarized as follows:
1. Compiler
On AIX, C ++ code is usually compiled using the built-in xlc. Here GCC is used for compilation and downloaded from IBM.
Gcc-4.0.0-1.aix5.3. c. rpm,
Gcc-cplu lus-4.0.0-1.aix5.3. c. rpm,
Libgcc-4.0.0-1.aix5.3. c. rpm,
Li tdcplu lus-4.0.0-1.aix5.3. c. rpm,
Li tdcplu lus-devel-4.0.0-1.aix5.3. c. rpm
Install these five packages respectively. : Http://www-03.ibm.com/servers/ai... linux/download.html
After the installation is successful, write a hello world mini-Program for testing. When the program is linked, a bunch of errors are reported, such:
Ld: 0711-317 ERROR: Undefined symbol: cout
Ld: 0711-317 ERROR: Undefined symbol:. ostream: operator <(char const *)
Ld: 0711-345 Use the-bloadmap or-bnoquiet option to obtain more information.
Collect2: ld returned 8 exit status
Cause: AIX does not load the stdc ++ library by default. You need to specify it by yourself. In the compilation, add-lstdc ++-L/usr/local/lib (libstdc ++. a directory ).
In addition, if C ++ code is compiled, it must be compiled using G ++. During AIX compilation, GCC compilation will still succeed, however, some C ++ features cannot be displayed during runtime, leading to errors. For example, I used exception handling in the program, but the file was compiled using GCC and found that the compilation was successful, however, the exception thrown out of throw is not caught in any way during the running, and G ++ is used for compilation.
2. Operating System SDK
Some APIs on AIX are different from those on linux. For example, the parameters in gethostbyname_r are different. In addition, some constants are not defined, for example, you need to define in your public header file:
# Ifndef AF_UNIX
# Define AF_UNIX 1
# Endif
# Ifndef AF_INET
# Define AF_INET 2
# Endif
# Ifndef PF_UNIX
# Define PF_UNIX AF_UNIX
# Endif
# Ifndef PF_INET
# Define PF_INET AF_INET
# Endif
# Ifndef AF_LOCAL
# Define AF_LOCAL AF_UNIX
# Endif
# Ifndef PF_LOCAL
# Define PF_LOCAL PF_UNIX
# Endif
3. Thread Security
If a program on AIX uses multiple threads, you must add-D_THREAD_SAFE or-D_THREAD_SAFE_ERRNO to the program during compilation. Check/usr/include/errno. h to find out the cause. Otherwise, the program will report a lot of strange errors, making your head big.
In addition, if you use a third-party library, check whether it has a single-threaded or multi-threaded version, such as the ct-lib library of the sybase Database, libct is split on AIX. so and libct_r.so, of course, you need to know how many bits, 32bit or 64bit, you have installed the operating system, and libct64.so and libct64_r.so are also available.
4. Makefile
You can install a GUN make file on AIX, so that you do not need to modify the Makefile file in linux, for example, you have used. so file, you cannot use the method of-l XX library, you must use the full path mode,. o files are linked together. For example, you need to use libsybdb. so, if you use-lsybdb,-L $ (SYBASE)/lib, The SO file is still not found during compilation. You can use $ (SYBASE)/lib/libsybdb. so directly compiles the full path, which is normal.
The above are some of the problems I found in practice, because I am not familiar with AIX, and I am not sure whether it is caused by my own configuration or other reasons, if any expert finds that there is a better way, hope to give you some advice. I also hope to add some other experiences. Thank you!
Next, we will introduce several good tools to access the file samba for AIX in the form of network neighbors. The linxu version is also available. In addition, check for Memory leakage: svmon-p pid-I N prints the resource usage of the Process PID Every N seconds.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service