8

I'm using libevent for a program, I compile my program on two computers A and B, on A the execution is successful, but on B I got the following errors:

error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

FYI:

A and B are with fedora system, on both A and B, I downloaded libevent-1.4.14b-stable.tar.gz, and install it through configure/make/make install.

on A

    [esolve@kitty temp]$ uname -r
    3.6.10-2.fc16.x86_64
    [esolve@kitty temp]$ ls -al /usr/local/lib64 | grep libevent
    [esolve@kitty temp]$ ls -al /usr/lib64 | grep libevent
    [esolve@kitty temp]$ ls -al /usr/lib | grep libevent
    lrwxrwxrwx   1 root root       32 May 21 00:25 libevent-1.4.so.2 -> /usr/local/lib/libevent-1.4.so.2
    [esolve@kitty temp]$ ls -al /usr/local/lib | grep libevent
    lrwxrwxrwx   1 root root     21 May 21 00:22 libevent-1.4.so.2 -> libevent-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 435304 May 21 00:22 libevent-1.4.so.2.2.0
    -rw-r--r--   1 root root 793178 May 21 00:22 libevent.a
    lrwxrwxrwx   1 root root     26 May 21 00:22 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 160352 May 21 00:22 libevent_core-1.4.so.2.2.0
    -rw-r--r--   1 root root 269580 May 21 00:22 libevent_core.a
    -rwxr-xr-x   1 root root    988 May 21 00:22 libevent_core.la
    lrwxrwxrwx   1 root root     26 May 21 00:22 libevent_core.so -> libevent_core-1.4.so.2.2.0
    lrwxrwxrwx   1 root root     27 May 21 00:22 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 342122 May 21 00:22 libevent_extra-1.4.so.2.2.0
    -rw-r--r--   1 root root 631804 May 21 00:22 libevent_extra.a
    -rwxr-xr-x   1 root root    995 May 21 00:22 libevent_extra.la
    lrwxrwxrwx   1 root root     27 May 21 00:22 libevent_extra.so -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root    953 May 21 00:22 libevent.la
    lrwxrwxrwx   1 root root     21 May 21 00:22 libevent.so -> libevent-1.4.so.2.2.0

on B:

    root@kitch server_agent]# uname -r
    3.8.5-201.fc18.x86_64
    [root@kitch server_agent]# ls -al /usr/lib | grep libevent
    lrwxrwxrwx   1 root root      32 Jun 14 17:09 libevent-1.4.so.2 -> /usr/local/lib/libevent-1.4.so.2
    [root@kitch server_agent]# ls -al /usr/local/lib | grep libevent
    lrwxrwxrwx   1 root root     21 Jun 14 16:03 libevent-1.4.so.2 -> libevent-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 435524 Jun 14 16:03 libevent-1.4.so.2.2.0
    -rw-r--r--   1 root root 805650 Jun 14 16:03 libevent.a
    lrwxrwxrwx   1 root root     26 Jun 14 16:03 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 164070 Jun 14 16:03 libevent_core-1.4.so.2.2.0
    -rw-r--r--   1 root root 270748 Jun 14 16:03 libevent_core.a
    -rwxr-xr-x   1 root root    994 Jun 14 16:03 libevent_core.la
    lrwxrwxrwx   1 root root     26 Jun 14 16:03 libevent_core.so -> libevent_core-1.4.so.2.2.0
    lrwxrwxrwx   1 root root     27 Jun 14 16:03 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root 339502 Jun 14 16:03 libevent_extra-1.4.so.2.2.0
    -rw-r--r--   1 root root 642916 Jun 14 16:03 libevent_extra.a
    -rwxr-xr-x   1 root root   1001 Jun 14 16:03 libevent_extra.la
    lrwxrwxrwx   1 root root     27 Jun 14 16:03 libevent_extra.so -> libevent_extra-1.4.so.2.2.0
    -rwxr-xr-x   1 root root    959 Jun 14 16:03 libevent.la
    lrwxrwxrwx   1 root root     21 Jun 14 16:03 libevent.so -> libevent-1.4.so.2.2.0
    [root@kitch server_agent]# ls -al /usr/lib64 | grep libevent
    [root@kitch server_agent]# ls -al /usr/local/lib64 | grep libevent

why my program get this error on B and are there any solutions? thanks!

misteryes
  • 2,167
  • 4
  • 32
  • 58

1 Answers1

12

Your "A" system has a symlink from /usr/lib/libevent-1.4.so.2 to /usr/local/lib/libevent-1.4.so.2 but system "B" does not. Chances are, if you create it then everything will start working.

The command should be as follows.

sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2

As an alternative, you can add /usr/local/lib to your library path as a test by exporting LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib as a temporary fix on system "B".

Peter Hall
  • 53,120
  • 14
  • 139
  • 204
Tom Scogland
  • 937
  • 5
  • 12
  • Iran the command 'sudo ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2' and I get symlink from /usr/lib/libevent-1.4.so.2 to /usr/local/lib/libevent-1.4.so.2, the problem is still there – misteryes Jun 14 '13 at 15:12
  • but export LD_LIBRARY_PATH works. however, before exporting, I only have $LD_LIBRARY_PATH is empty, why? – misteryes Jun 14 '13 at 15:16
  • It may be that your B system has a different default ld path than the A system does. That would not explain why the symlink does not work though. Diagnosing from here it would be best to look at your ld.so.conf settings to see what directories are being checked for libraries. As to LD_LIBRARY_PATH, it is completely normal for that to be empty, I included the reference to an existing value only to ward against the possibility that you might have one set in your shell configuration. – Tom Scogland Jun 14 '13 at 15:25
  • 1
    sudo ln -s /usr/lib/libevent-2.1.so.6 /usr/lib64/libevent-2.1.so.6 .....for libevent-1.4.so.2 the same because you have x86_64. – Michael Popovich Sep 06 '17 at 06:47