Tuesday, March 20, 2007

how to make .so files load in unix

Ive had this problem too many times and so i should blog the solution. The problem usually looks something like this: You try to run something and you get an error screaming about failing to load some file ending in .so

example:

failed: Can't load '/app/teamsite/iw-perl/site/lib/auto/DBD/Oracle/
Oracle.so' for module DBD::Oracle: ld.so.1: perl: fatal: libnnz10.so: open failed: No such
file or directory at /app/teamsite/iw-perl/lib/DynaLoader.pm line 229.

solution:

All these .so problems seem to be have a common solution. You need tell unix where to look for your libraries. This is how you do it.
  1. Figure out where your application has its .so files. Usually this is in a directory called lib, and it usually contains more then one .so file.
  2. You need to become root, and run this command:
  3. crle
  4. write down everything which is output, because if you break things you will need to go back to this. On solaris 10 this is the important piece which has to always be in the output: Default Library Path (ELF): /usr/lib
  5. Now we need to add our library locations to the Default Library Path, run this as root:
  6. crle -c /var/ld/ld.config -l /usr/lib:/your/directory/where/the/so/files/are
  7. exit root
Now try to run your application and see if it runs. If it does not run then it may complain about another .so file in another directory which you missed. You will need to add it to the end of the path in step 5 like this:
crle -c /var/ld/ld.config -l /usr/lib:/your/directory/where/the/so/files/are:/another/lib/path

Important: if you remove the /usr/lib part from the Default Library Path, shit will hit the fan.
Use this at your own risk.

No comments:

Post a Comment