LIBPATH and open-source packages on IBM AIX

LIBPATH and open-source packages on IBM AIX

Friday afternoon. What can be better than to compile a small program on IBM AIX? ;-) OK, I tried to do it and as you can imagine, I've got an error. The cryptical error you see above. What the heck happens?

GCC is fresh installed from IBM AIX Toolbox for Open Source applications. There are no updates. Everything must just work!

Let's start with the investigation. First check if it is true. See which libraries GCC want to use.

No alt text provided for this image

It tries to use /usr/lib/libiconv.a, but remember - GCC was installed from AIX Toolbox. It means it should use libraries from /opt/freeware/lib. If we look in /opt/freeware/lib we will find another libiconv.a there and gcc works just fine with it:

No alt text provided for this image

If the problem can be solved by setting LIBPATH variable to /opt/freeware/lib, then it usually means, that we have incorrect LIBPATH setting.

LIBPATH is a special AIX variable and it shows to AIX loader, where it should search for dynamic libraries. It is the same as LD_LIBRARY_PATH in Linux, but shorter ;-) It is very useful if you have several different versions of the same library and want to run your application with a specific version. For example some applications don't use AIX OpenSSL, but their own OpenSSL. Then you can instruct them to use another OpenSSL library by setting the variable.

In my case someone indeed decided to disable all other paths for shared libraries, except standard /usr/lib and set the LIBPATH variable:

No alt text provided for this image

The problem was easy solved by unsetting the variable.

No alt text provided for this image

If the varialbe is not set, AIX will search for shared libraries in the directories which were specified during the compilation time. In this case it will find the correct libiconv.a library:

No alt text provided for this image

The path where the program expects to find its shared libraries you can find with the command dump(1):

No alt text provided for this image

The value with index 0 is the library search path specified at linking time with the option -blibpath to AIX linker ld(1).

Have fun and nice weekend!

Andrey

Udo Sachs

Head of Competence Center Power Systems at SVA System Vertrieb Alexander GmbH

2 年

Very helpful. Thanks Andrey for sharing ??

要查看或添加评论,请登录

???????Andrey Klyachkin的更多文章

社区洞察

其他会员也浏览了