c++linkeraixlibstdc++gcc4.8

undefined Reference to "_ZNSt5__padIcSt11char_traitsIcEE6_S_padERSt8ios_basecPcPKcllb" symbol is not exported from libstdc++.a(libstdc++.so.6)


I am able to build my code successfully but getting following error while trying to run it. I am on AIX7.1 using GCC4.8.5.

0509-130 Symbol resolution failed for libadobelinguistic.a because: 0509-136 Symbol _ZNSt5__padIcSt11char_traitsIcEE6_S_padERSt8ios_basecPcPKcllb (number 94) is not exported from dependent module /user/unicore/rs6000aix/compiler/gcc4.8.5/aix6.1/lib/libstdc++.a(libstdc++.so.6). 0509-022 Cannot load module . 0509-026 System error: Cannot run a file that does not have a valid format. 0509-192 Examine .loader section symbols with the 'dump -Tv' command."}

As suggested at few places I used -Wl,--no-undefined flag to fail the project at compilation time. but compilation is not failing.

demangled function:

std::__pad<char, std::char_traits<char> >::_S_pad(std::ios_base&, char, char*, char const*, long, long, bool)

I am unable to find reference to this function.

Moreover as suggested at few places In case of such errors you need to set LIBPATH variable in case of AIX. I have libpath variable set to

LIBPATH=/user/unicore/rs6000aix/compiler/gcc4.8.5/aix6.1/lib:/opt/freeware/lib:/user/unicore/rs6000aix/compiler/gcc4.8.5/aix6.1/lib/gcc/powerpc-ibm-aix6.1.0.0/4.8.5:/opt/freeware/lib/pthread/ppc64

still it is not working.

I found a reference to it https://sourceforge.net/p/slo/feature-requests/4/. but it is not helpful.

Edit: seems like libstdc++ is causing issue on the AIX7.1. we have system libstdc++ and libstdc++ of gcc4.8.5. when I link to system libstdc++ gdb runs successfully but my program fails but when i set path to libstdc++ in gcc4.8.5. GDB doesn't run but my executable runs. seems like system libstdc++ and gcc4.8.5 libstdc++ are not compatible.


Solution

  • Issue was with libstdc++. By default LIBPATH was set to opt/freeware/lib where libstdc++ was available. While compiling my source was getting linked to libstdc++ available at the 'opt/freeware/lib' location. where as at run time it was looking for 'libstdc++' available in the gcc4.8.5. causing the issue.

    setting LIBPATH to gcc lib directory solved the issue.