IBM Support

IBM AIX: LIBPATH and exec(): 0509-036 Cannot load program

Question & Answer


Question

IBM AIX: LIBPATH and exec(): 0509-036 Cannot load program

Answer

The LIBPATH environment variable tells AIX applications where to find shared libraries when located in a different directories than those specified in the header section of the executable.  If no LIBPATH variable is specified, the sytem loader will  load those shared libraries and archive members from default locations found in the header.

To view the loader section of an AIX excutable, use the 'dump -H' command.  In the example below, the locations of the shared objects and archives specified by the '-L' linker option are generated and stored in the executable's header.    

For example,
$ cc -o a.out main.c -labc -L/project/test/lib
$dump -H a.out
a.out:
***Loader Section***
Loader Header Information
VERSION# #SYMtableENT #RELOCent LENidSTR
0x00000001 0x00000007 0x00000010 0x00000037
#IMPfilID OFFidSTR LENstrTBL OFFstrTBL
0x00000002 0x00000188 0x0000002a 0x000001bf
***Import File Strings***
INDEX PATH BASE MEMBER
0/project/test/lib:/usr/lpp/xlopt:/usr/lib:/lib
1 libabc.a shr.o

If the LIBPATH environment variable is defined, the system loader refers to it in order to search referenced shared objects and libraries that contain shared archive members, when the executable file is invoked.

For example, if the LIBPATH is set to:
LIBPATH=/project/build/lib

The system loader will add the text string value of LIBPATH in front of the PATH information stored in the first (index 0) loader header section of the XCOFF header of the executable.   The system loader will then search for the referenced shared objects and libraries in the following order:

1. /project/build/lib
2. /project/test/lib
3. /usr/lpp/xlopt
4. /usr/lib
5. /lib

If a shared object cannot be found by the system loader when trying to start an executable, an error message similar to the following will be seen:
exec(): 0509-036 Cannot load program <exe> because of the following errors:
     0509-022 Cannot load library libone.so.
     0509-026 System error: A file or directory in the path name does not exist.

The missing objects will be listed with 0509-022 error messages. To resolve this error, set the LIBPATH environment variable to include the directory that contains the shared object and restart the application.

 

SUPPORT:

If you have a valid and active IBM Support Subscription, when reporting a Java issue, please follow the step-by-step instructions below to contact IBM to open a case for software under warranty or with an active and valid support contract.  The technical support specialist assigned to your case will confirm that you have completed these steps.

a.  Document and/or take screen shots of all symptoms, errors, and/or messages that might have occurred

b.  Capture any logs or data relevant to the situation.

c.  Contact IBM to open a case:

   -For electronic support, please visit the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, please visit the web page:
      https://www.ibm.com/planetwide/

d.  Provide a good description of your issue and reference this technote

e.  Upload all of the details and data to your case

   -You can attach files to your case in the IBM Support Community
   -Or Upload data to IBM testcase server analysis:

    http://www.ibm.com/support/docview.wss?uid=ibm10733581

f.  Click here to submit feedback for this document.


[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"Component":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

More support for:
AIX

Software version:
All Versions

Operating system(s):
AIX

Document number:
885064

Modified date:
20 May 2019

UID

ibm10885064

Manage My Notification Subscriptions