javer / gentoo-overlay

Gentoo Portage Overlay [javer]
9 stars 11 forks source link

compile problem: cannot find -lmysqlclient_r #4

Closed dreeh closed 10 years ago

dreeh commented 10 years ago

Hello,

i've found your overlay, thats great. Unfortunately i'm not able to compile. After compiling it fails while linking:

[ 99%] Building CXX object hphp/test/CMakeFiles/test.dir/ext/test_parser_expr.cpp.o
Linking CXX executable hhvm
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lmysqlclient_r
collect2: error: ld returned 1 exit status
make[2]: *** [hphp/hhvm/hhvm] Error 1
make[1]: *** [hphp/hhvm/CMakeFiles/hhvm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Do you have any idea to solve that? Which information do you need?

Thanks, Denny

javer commented 10 years ago

Which version or fork of MySQL are you using?

dreeh commented 10 years ago

I have dev-db/mysql-5.5.32 installed. is any special USE flag needed?

[I] dev-db/mysql
     Available versions:  [M]4.0.27-r1 [M]4.1.22-r1 [M]5.0.96 5.1.70 (~)5.5.32 {berkdb big-tables cluster +community debug embedded extraengine jemalloc latin1 max-idx-128 minimal pbxt (+)perl profiling raid selinux ssl static systemtap tcmalloc test xtradb}
     Installed versions:  5.5.32(12:24:47 07/26/13)(community latin1 perl ssl -cluster -debug -embedded -extraengine -jemalloc -max-idx-128 -minimal -profiling -selinux -static -systemtap -tcmalloc -test)
     Homepage:            http://www.mysql.com/
     Description:         A fast, multi-threaded, multi-user SQL database server.
javer commented 10 years ago

It looks like a bug: http://bugs.gentoo.org/440918

Do you have libmysqlclient_r.so in the /usr/lib directory? If not, you should create symlink:

cd /usr/lib
ln -s mysql/libmysqlclient_r.so libmysqlclient_r.so
ln -s mysql/libmysqlclient_r.so libmysqlclient_r.so.18
ln -s mysql/libmysqlclient_r.so libmysqlclient_r.so.18.0.0

Also check whether you have libmysqlclient_r.so in the /usr/lib/mysql directory. If not:

cd /usr/lib/mysql
ln -s libmysqlclient.so libmysqlclient_r.so
ln -s libmysqlclient.so libmysqlclient_r.so.18
ln -s libmysqlclient.so libmysqlclient_r.so.18.0.0
dreeh commented 10 years ago

i check that already. in /usr/lib i have these files:

# find . -name libmysqlclient_r*
./mysql/libmysqlclient_r.so.18.0.0
./mysql/libmysqlclient_r.a
./mysql/libmysqlclient_r.so
./mysql/libmysqlclient_r.so.18

in /usr/lib/mysql there is a symbolic link for libmysqlclient_r.so:

# ll libmysqlclient_r.so
lrwxrwxrwx 1 root root 17 Jul 26 12:24 libmysqlclient_r.so -> libmysqlclient.so
javer commented 10 years ago

Have you successfully compiled HHVM? If not, please try the latest version committed just now and let me know.

dreeh commented 10 years ago

Thank you for updating it. No, it failed with the same issue. I tried also 2.3.1 and 9999.

Maybe its related to gcc 4.8.2?

dreeh commented 10 years ago

I found a solution.

I had to create symbolic links in /usr/lib:

# ln -s ./mysql/libmysqlclient_r.so libmysqlclient_r.so
# ln -s ./mysql/libmysqlclient.so libmysqlclient.so

With this, it compiles. Why this is needed? Do you have an idea to handle this?

When i'm using hhvm, it fails:

$ hhvm 
/usr/lib/hhvm/bin/hhvm: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

After creating a symbilc link in /usr/lib/hhvm/lib:

# ln -s /usr/lib/mysql/libmysqlclient.so.18 libmysqlclient.so.18

it's working.

javer commented 10 years ago

I think some software created libmysqlclient_r.so in /usr/lib and therefore HHVM uses this directory instead of /usr/lib/mysql because HHVM determines library directory only by location of one file libmysqlclient_r.so and it does not check for existence of another necessary files and/or symlinks. See https://github.com/facebook/hhvm/blob/master/CMake/FindMySQL.cmake#L70 for details.

There is no libmysqlclient_r.so in /usr/lib in my Gentoo installation despite of a lot software installed on the server, but all necessary files are located in /usr/lib/mysql.

javer commented 10 years ago

I'll close this issue since it already contains a solution for others who hits the same problem.

rosmanov commented 10 years ago

I have the same issue on Gentoo x86_64: /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lmysqlclient_r . But I have /usr/lib/mysql/libmysqlclient_r.so installed with mariadb package.

build.log: http://bpaste.net/show/174229/ .

I wonder why configure script is referring to lib32: -- MySQL Include dir: /usr/include/mysql library dir: /usr/lib32 Well, I have /usr/lib32/libmysqlclient_r.so file. But the arch is x86_64!

$ ldconfig -p  | grep mysql
    libmysqlclient_r.so.16 (libc6) => /usr/lib32/libmysqlclient_r.so.16
    libmysqlclient_r.so (libc6) => /usr/lib32/libmysqlclient_r.so
    libmysqlclient.so.18 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.18
    libmysqlclient.so.16 (libc6) => /usr/lib32/libmysqlclient.so.16
    libmysqlclient.so (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so
    libmysqlclient.so (libc6) => /usr/lib32/libmysqlclient.so