rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.79k stars 314 forks source link

Fix the libexec.so path #416

Closed tr4v3ler closed 2 years ago

tr4v3ler commented 2 years ago

After compiling, I tried to execute bear, but the following error occurred:

$ bear -- make -j8 O=out ARCH=arm64
ERROR: ld.so: object '/usr/local/$LIB/bear/libexec.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

The default path of libexec.so here should be /usr/local/lib/bear/libexec.so, repairing this path can solve the first problem. By the way, I use Ubuntu 20.04.3, and the bear version is 3.0.16.

rizsotto commented 2 years ago

Hey @tr4v3ler , have you read the INSTALL.md file? It has the instruction for Ubuntu users. If that not helps, let me know.

TC500 commented 2 years ago

@rizsotto bear install at /usr/local/bin , ld.so try to find at /usr/local/$LIB/bear/libexec.so, but the $LIB is empty follow the INSTALL.md not work

rizsotto commented 2 years ago

Hey @TC500 , thanks to come over here.

First, I would like to point out that $LIB in the error message does not refer to an environment variable called LIB. This is a defined symbol for the dynamic linker on your system, which expands in a LD_PRELOAD usage. (Read man ld.so for more.)

Depending on your Linux distribution and the architecture of your machine, the $LIB expands to lib, lib64, lib/i386-linux-gnu, etc... Check out what is the directory name in /usr that contains your libc.so.

Fedora running on a x86_64, this is /usr/lib64/libc.so, therefore the $LIB expands to lib64. In this case the libexec.so should be installed as /usr/local/lib64/bear/libexec.so.

CMake somehow does not pay attention for this important detail. And it installs the library as /usr/local/lib/bear/libexec.so. (That's why the INSTALL.md gives instruction how to change that.)

Here are some tips:

TC500 commented 2 years ago

@rizsotto thanks, ubuntu 20 $LIB expand to lib/x86_64-linux-gnu, and set -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu solve this problem