I have a C executable which depends on libdb2.a. Yet, when the executable is called, the following error popped up:
exec(): 0509-036 Cannot load program /my/path/my_c_exe because of the following errors:
0509-150 Dependent module libdb2.a(shr.o) could not be loaded.
0509-022 Cannot load module libdb2.a(shr.o).
0509-026 System error: A file or directory in the path name does not exist.
Later, it is found that I should add the following env setting in the file .profile
in my home directory:
LIBPATH=/db2/v84bc/sqllib/lib64
export LIBPATH
Yes, the issue is resolved. But I am still bewildered at the original error because the static library libdb2.a
should be built into the c executable /my/path/my_c_exe
in compile time. The executable should not have been looking for the static library it depends on in run time, should it? If db2 is a shared object, I can see the rationale. But for a static library, the error is beyond my understanding.
Any hints on the cause of this error? Or, though libdb2.a
is named as a static library, it actually is a shared object? How to determine whether a library is a static one or a shared object, other than looking at the suffix (.a or .so)?