LIBPATH and open-source packages on IBM AIX
??????Andrey Klyachkin
#1 in Automating IBM Power and IBM AIX Infrastructure | POWER DevOps | IT Infrastructure Automation | Speaker | Trainer | Author | IBM Champion | IBM AIX Community Advocate
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.
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:
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:
领英推荐
The problem was easy solved by unsetting the variable.
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:
The path where the program expects to find its shared libraries you can find with the command dump(1):
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
Head of Competence Center Power Systems at SVA System Vertrieb Alexander GmbH
2 年Very helpful. Thanks Andrey for sharing ??