Monday, April 13, 2009

Fatal Error - libm.so.2: open failed: No such file or directory

Problem:
ld.so.1: Read_Files: fatal: libm.so.2: open failed: No such file or directory

how I got:
I got the above error, while executing C++ executable Read_Files in solaris 5.8 OS.

Reason for error:
The problem is that on Solaris 8 and Solaris 9 libm.so.2 is not present in usr/lib. (an older version of the libm.so. library is used), whereas programms built on Solaris 5.10, link with libm.so.2 without any proble.

Solution1: Copy the library libm.so.2 into /usr/lib/ if u have sufficient root permision to the system

Solution 2: On solaris 5.8/9 system copy the executable to your local directory say -/mydir from where you had compiled ( i.e from solaris 5.10)

2.1 Copy the library libm.so.2 from another system ( which
    has 5.10)  into  /mydir.

2.2. add your directory path to LD_LIBRARY_PATH.i.e
$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mydir

2.3 Execute the binary as ./Read_Files. 
            The error would have gone. Enjoy maadi !!!