Open wahjava opened 8 years ago
@wahjava What's the output of mysql_config
? And, what is the contents of /usr/local/lib/mysql ?
@ryantm ---
λ mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/include/mysql -I/usr/local/include/mysql/.. -pipe -fstack-protector -fno-strict-aliasing -g -DNDEBUG]
--include [-I/usr/local/include/mysql -I/usr/local/include/mysql/..]
--libs [-L/usr/local/lib/mysql -lmysqlclient -pthread -lz -lm -lexecinfo -L/usr/local/lib]
--libs_r [-L/usr/local/lib/mysql -lmysqlclient_r -pthread -lz -lm -lexecinfo -L/usr/local/lib]
--plugindir [/usr/local/lib/mysql/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [10.0.15]
--libmysqld-libs [-L/usr/local/lib/mysql -lmysqld -L/usr/local/lib]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/include/mysql]
pkglibdir [/usr/local/lib/mysql]
plugindir [/usr/local/lib/mysql/plugin]
λ ls /usr/local/lib/mysql/
libmysqlclient.a libmysqlclient.so.18 libmysqlclient_r.so libmysqld.a libmysqld.so.18
libmysqlclient.so libmysqlclient_r.a libmysqlclient_r.so.18 libmysqld.so plugin
Same here on exherbo:
$ cabal build -v
Using a sandbox located at /home/jule/git/hdbc-mysql/.cabal-sandbox
Reading installed packages...
/usr/host/bin/ghc-pkg dump '--package-db=/home/jule/git/hdbc-mysql/.cabal-sandbox/x86_64-linux-ghc-8.0.1-packages.conf.d' -v0
/usr/host/bin/ghc --print-libdir
Found no modified add-source deps.
creating dist/setup
./dist/setup/setup build --verbose=2 --builddir=dist --jobs=8
Component build order: library
creating dist/build
creating dist/build/autogen
Building HDBC-mysql-0.6.6.2...
/usr/host/bin/ghc-pkg init dist/package.conf.inplace
Preprocessing library HDBC-mysql-0.6.6.2...
Building library...
creating dist/build
/usr/host/bin/ghc --make -fbuilding-cabal-package -O -j8 -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -I/usr/host/include/mysql -optP-include -optPdist/build/autogen/cabal_macros.h -this-unit-id HDBC-mysql-0.6.6.2-IlhfsN644vr5gZnmKDFoOD -hide-all-packages -no-user-package-db -package-db /home/jule/git/hdbc-mysql/.cabal-sandbox/x86_64-linux-ghc-8.0.1-packages.conf.d -package-db dist/package.conf.inplace -package-id HDBC-2.4.0.1-52zOH007JHkETflZA5wmRm -package-id base-4.9.0.0 -package-id bytestring-0.10.8.1 -package-id time-1.6.0.1 -package-id utf8-string-1.0.1.1-2T8mBCuEDlXDo8zed8Onw4 -XHaskell98 Database.HDBC.MySQL Database.HDBC.MySQL.Connection Database.HDBC.MySQL.RTS -Wall
Linking...
[(SimpleUnitId (ComponentId
"HDBC-2.4.0.1-52zOH007JHkETflZA5wmRm"),PackageIdentifier {pkgName =
PackageName {unPackageName = "HDBC"}, pkgVersion = Version {versionBranch =
[2,4,0,1], versionTags = []}},ModuleRenaming True []),(SimpleUnitId
(ComponentId "base-4.9.0.0"),PackageIdentifier {pkgName = PackageName
{unPackageName = "base"}, pkgVersion = Version {versionBranch = [4,9,0,0],
versionTags = []}},ModuleRenaming True []),(SimpleUnitId (ComponentId
"bytestring-0.10.8.1"),PackageIdentifier {pkgName = PackageName {unPackageName
= "bytestring"}, pkgVersion = Version {versionBranch = [0,10,8,1], versionTags
= []}},ModuleRenaming True []),(SimpleUnitId (ComponentId
"time-1.6.0.1"),PackageIdentifier {pkgName = PackageName {unPackageName =
"time"}, pkgVersion = Version {versionBranch = [1,6,0,1], versionTags =
[]}},ModuleRenaming True []),(SimpleUnitId (ComponentId
"utf8-string-1.0.1.1-2T8mBCuEDlXDo8zed8Onw4"),PackageIdentifier {pkgName =
PackageName {unPackageName = "utf8-string"}, pkgVersion = Version
{versionBranch = [1,0,1,1], versionTags = []}},ModuleRenaming True [])]
/usr/bin/x86_64-pc-linux-gnu-ar -r dist/build/objs-14517/libHSHDBC-mysql-0.6.6.2-IlhfsN644vr5gZnmKDFoOD.a dist/build/Database/HDBC/MySQL.o dist/build/Database/HDBC/MySQL/Connection.o dist/build/Database/HDBC/MySQL/RTS.o
/usr/bin/x86_64-pc-linux-gnu-ar: creating dist/build/objs-14517/libHSHDBC-mysql-0.6.6.2-IlhfsN644vr5gZnmKDFoOD.a
/usr/host/bin/ghc -shared -dynamic -lmysqlclient '-dynload deploy' -optl-Wl,-rpath,/home/jule/git/hdbc-mysql/.cabal-sandbox/lib/x86_64-linux-ghc-8.0.1/HDBC-2.4.0.1-52zOH007JHkETflZA5wmRm -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/array-0.5.1.1 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/base-4.9.0.0 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/binary-0.8.3.0 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/bytestring-0.10.8.1 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/containers-0.5.7.1 -optl-Wl,-rpath,/home/jule/git/hdbc-mysql/.cabal-sandbox/lib/x86_64-linux-ghc-8.0.1/convertible-1.1.1.0-2fPmnMYRPdO896jU4ffPoZ -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/deepseq-1.4.2.0 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/x86_64-linux-ghc-8.0.1/mtl-2.2.1-6qsR1PHUy5lL47Hpoa4jCM -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/x86_64-linux-ghc-8.0.1/old-locale-1.0.0.7-6glXNhHF891B41ZfuI8hU8 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/x86_64-linux-ghc-8.0.1/old-time-1.1.0.3-IcvdkJUsE9M8t3io8peAEp -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/rts -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/x86_64-linux-ghc-8.0.1/text-1.2.2.0-3a9dYmy0lx7FK5kPXUTTi5 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/time-1.6.0.1 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/ghc-8.0.1/transformers-0.5.2.0 -optl-Wl,-rpath,/usr/x86_64-pc-linux-gnu/lib/x86_64-linux-ghc-8.0.1/utf8-string-1.0.1.1-2T8mBCuEDlXDo8zed8Onw4 -no-auto-link-packages -no-user-package-db -package-db /home/jule/git/hdbc-mysql/.cabal-sandbox/x86_64-linux-ghc-8.0.1-packages.conf.d -package-db dist/package.conf.inplace -package-id HDBC-2.4.0.1-52zOH007JHkETflZA5wmRm -package-id base-4.9.0.0 -package-id bytestring-0.10.8.1 -package-id time-1.6.0.1 -package-id utf8-string-1.0.1.1-2T8mBCuEDlXDo8zed8Onw4 dist/build/Database/HDBC/MySQL.dyn_o dist/build/Database/HDBC/MySQL/Connection.dyn_o dist/build/Database/HDBC/MySQL/RTS.dyn_o -o dist/build/libHSHDBC-mysql-0.6.6.2-IlhfsN644vr5gZnmKDFoOD-ghc8.0.1.so
/usr/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status
`x86_64-pc-linux-gnu-cc' failed in phase `Linker'. (Exit code: 1)
Here's a dirty hack that lets me build it. Pretty sure that's not the correct solution though.
Here is a successful build on Ubuntu for reference:
$ cabal build -v
Saved package config file is outdated:
• the Cabal version changed from Cabal-1.22.5.0 to Cabal-1.24.0.0
• the compiler changed from ghc-7.10 to ghc-8.0
Re-run the 'configure' command.
creating dist/setup
./dist/setup/setup build --verbose=2 --builddir=dist --jobs=4
Component build order: library
creating dist/build
creating dist/build/autogen
Building HDBC-mysql-0.6.6.2...
/usr/bin/ghc-pkg init dist/package.conf.inplace
Preprocessing library HDBC-mysql-0.6.6.2...
Building library...
creating dist/build
/usr/bin/ghc --make -fbuilding-cabal-package -O -j4 -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -I/usr/include/mysql -optP-include -optPdist/build/autogen/cabal_macros.h -this-package-key HDBCm_4lEfmgmYEzVItbawq4YOCp -hide-all-packages -package-db dist/package.conf.inplace -package-id HDBC-2.4.0.1-2LkVHJm3eACC0IM4OBp3Zx -package-id base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -package-id bytestring-0.10.6.0-9a873bcf33d6ce2fd2698ce69e2c1c66 -package-id time-1.5.0.1-1b9a502bb07a3e6f4d6935fbf9db7181 -package-id utf8-string-1.0.1.1-BSOhbZGxHIuHytQK3cL5fK -XHaskell98 Database.HDBC.MySQL Database.HDBC.MySQL.Connection Database.HDBC.MySQL.RTS -Wall
Linking...
[(InstalledPackageId "HDBC-2.4.0.1-2LkVHJm3eACC0IM4OBp3Zx",PackageIdentifier
{pkgName = PackageName {unPackageName = "HDBC"}, pkgVersion = Version
{versionBranch = [2,4,0,1], versionTags = []}},ModuleRenaming True
[]),(InstalledPackageId
"base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d",PackageIdentifier {pkgName =
PackageName {unPackageName = "base"}, pkgVersion = Version {versionBranch =
[4,8,2,0], versionTags = []}},ModuleRenaming True []),(InstalledPackageId
"bytestring-0.10.6.0-9a873bcf33d6ce2fd2698ce69e2c1c66",PackageIdentifier
{pkgName = PackageName {unPackageName = "bytestring"}, pkgVersion = Version
{versionBranch = [0,10,6,0], versionTags = []}},ModuleRenaming True
[]),(InstalledPackageId
"time-1.5.0.1-1b9a502bb07a3e6f4d6935fbf9db7181",PackageIdentifier {pkgName =
PackageName {unPackageName = "time"}, pkgVersion = Version {versionBranch =
[1,5,0,1], versionTags = []}},ModuleRenaming True []),(InstalledPackageId
"utf8-string-1.0.1.1-BSOhbZGxHIuHytQK3cL5fK",PackageIdentifier {pkgName =
PackageName {unPackageName = "utf8-string"}, pkgVersion = Version
{versionBranch = [1,0,1,1], versionTags = []}},ModuleRenaming True [])]
/usr/bin/ar -r dist/build/objs-1052/libHSHDBC-mysql-0.6.6.2-4lEfmgmYEzVItbawq4YOCp.a dist/build/Database/HDBC/MySQL.o dist/build/Database/HDBC/MySQL/Connection.o dist/build/Database/HDBC/MySQL/RTS.o
/usr/bin/ar: creating dist/build/objs-1052/libHSHDBC-mysql-0.6.6.2-4lEfmgmYEzVItbawq4YOCp.a
/usr/bin/strip dist/build/objs-1052/libHSHDBC-mysql-0.6.6.2-4lEfmgmYEzVItbawq4YOCp.a --strip-unneeded
/usr/bin/ghc -shared -dynamic -lmysqlclient '-dynload deploy' -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/HDBC-2.4.0.1-2LkVHJm3eACC0IM4OBp3Zx -optl-Wl,-rpath,/usr/lib/ghc/array_67iodizgJQIIxYVTp4emlA -optl-Wl,-rpath,/usr/lib/ghc/base_HQfYBxpPvuw8OunzQu6JGM -optl-Wl,-rpath,/usr/lib/ghc/binar_3uXFWMoAGBg0xKP9MHKRwi -optl-Wl,-rpath,/usr/lib/ghc/rts -optl-Wl,-rpath,/usr/lib/ghc/bytes_6VWy06pWzJq9evDvK2d4w6 -optl-Wl,-rpath,/usr/lib/ghc/conta_2C3ZI8RgPO2LBMidXKTvIU -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/convertible-1.1.1.0-7kgf5etK6BBEHjJ0yy2W9s -optl-Wl,-rpath,/usr/lib/ghc/deeps_6vMKxt5sPFR0XsbRWvvq59 -optl-Wl,-rpath,/usr/lib/ghc/ghcpr_8TmvWUcS1U1IKHT0levwg3 -optl-Wl,-rpath,/usr/lib/ghc/integ_2aU3IZNMF9a7mQ0OzsZ0dS -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/mtl-2.2.1-8momq8BEamE2D2td4EjbI6 -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/old-locale-1.0.0.7-ELmjHWuDhUcFiOyFLZ49NT -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/old-time-1.1.0.3-HzR15Sum2ZRAJx4k8whG1D -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/text-1.2.2.1-BKb3DGJ0RPHAf8HuHkpsM1 -optl-Wl,-rpath,/usr/lib/ghc/time_FTheb6LSxyX1UABIbBXRfn -optl-Wl,-rpath,/usr/lib/ghc/trans_GZTjP9K5WFq01xC9BAGQpF -optl-Wl,-rpath,/home/ryantm/.cabal/lib/x86_64-linux-ghc-7.10.3/utf8-string-1.0.1.1-BSOhbZGxHIuHytQK3cL5fK -this-package-key HDBCm_4lEfmgmYEzVItbawq4YOCp -no-auto-link-packages -package-db dist/package.conf.inplace -package-id HDBC-2.4.0.1-2LkVHJm3eACC0IM4OBp3Zx -package-id base-4.8.2.0-0d6d1084fbc041e1cded9228e80e264d -package-id bytestring-0.10.6.0-9a873bcf33d6ce2fd2698ce69e2c1c66 -package-id time-1.5.0.1-1b9a502bb07a3e6f4d6935fbf9db7181 -package-id utf8-string-1.0.1.1-BSOhbZGxHIuHytQK3cL5fK dist/build/Database/HDBC/MySQL.dyn_o dist/build/Database/HDBC/MySQL/Connection.dyn_o dist/build/Database/HDBC/MySQL/RTS.dyn_o -o dist/build/libHSHDBC-mysql-0.6.6.2-4lEfmgmYEzVItbawq4YOCp-ghc7.10.3.so
In-place registering HDBC-mysql-0.6.6.2...
/usr/bin/ghc-pkg update - --global --user '--package-db=dist/package.conf.inplace'
@hasufell it builds for me on Ubuntu with your "dirty hack".
I should also point out that the title of this issue isn't exactly correct, because on NixOs it builds fine even though the libraries are definitely not in /usr/lib.
https://downloads.haskell.org/~ghc/7.6.3/docs/html/users_guide/using-shared-libs.html mentions FreeBSD so that makes me think the sharedOptions thing isn't a hack. Do we need to hide it behind some kind of OS guard though?
really strange, i had the same problem on Linux CentOS 7,
i'm not sure it's a Haskell specific problem, it seems that the Gold version of linker could not find the mysqlclient library even when the library is well installed:
[3 of 3] Compiling Database.HDBC.MySQL ( Database/HDBC/MySQL.hs, dist/build/Database/HDBC/MySQL.o )
/usr/bin/ld.gold: error: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status
gcc' failed in phase
Linker'. (Exit code: 1)
in my case my libraries are here: [root@localhost Downloads]# ls -la /usr/lib64/mysql/libmysqlclient* lrwxrwxrwx. 1 root root 17 Jun 29 16:35 /usr/lib64/mysql/libmysqlclient_r.so -> libmysqlclient.so lrwxrwxrwx. 1 root root 20 Jun 29 16:35 /usr/lib64/mysql/libmysqlclient.so -> libmysqlclient.so.18 lrwxrwxrwx. 1 root root 24 Jun 29 16:33 /usr/lib64/mysql/libmysqlclient.so.18 -> libmysqlclient.so.18.0.0 -rwxr-xr-x. 1 root root 3135672 Aug 4 2017 /usr/lib64/mysql/libmysqlclient.so.18.0.0
and ldconfig is ok, it had mysql in is search path: [root@localhost Downloads]# ldconfig -v 2>/dev/null | grep -v ^$'\t' /usr/lib64/dyninst: /usr/lib64/iscsi: /usr/lib64/mysql: /usr/lib64/qt-3.3/lib: /usr/lib64/xulrunner: /lib: /lib64: /lib/sse2: (hwcap: 0x0000000004000000) /lib/i686: (hwcap: 0x0008000000000000) /lib64/sse2: (hwcap: 0x0000000004000000) /lib64/tls: (hwcap: 0x8000000000000000)
the only solution i found is to put the mysqlclient lib directly in /usr/lib64 and not in the mysql subdirectory. But i did not wanted to move it: So i created a symbolic link that takes no more place and leave the library in its original place: cd /usr/lib64 ln -s mysql/libmysqlclient.so libmysqlclient.so ls -la libmysqlclient.so lrwxrwxrwx. 1 root root 23 Jun 29 17:03 libmysqlclient.so -> mysql/libmysqlclient.so
and this times the ld.gold linker find well the mysqlclient library:
cabal install HDBC-mysql Resolving dependencies... [1 of 1] Compiling Main ( /tmp/cabal-tmp-29073/HDBC-mysql-0.7.1.0/dist/setup/setup.hs, /tmp/cabal-tmp-29073/HDBC-mysql-0.7.1.0/dist/setup/Main.o )
/tmp/cabal-tmp-29073/HDBC-mysql-0.7.1.0/dist/setup/setup.hs:38:21: warning: [-Wdeprecations] In the use of ‘rawSystemProgramStdoutConf’ (imported from Distribution.Simple.Program): Deprecated: "use getDbProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Oct 2018)." | 38 | let mysqlConfig = rawSystemProgramStdoutConf verbosity mysqlConfigProgram (withPrograms lbi) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Linking /tmp/cabal-tmp-29073/HDBC-mysql-0.7.1.0/dist/setup/setup ... Configuring HDBC-mysql-0.7.1.0... Preprocessing library for HDBC-mysql-0.7.1.0.. Building library for HDBC-mysql-0.7.1.0.. [1 of 3] Compiling Database.HDBC.MySQL.Connection ( dist/build/Database/HDBC/MySQL/Connection.hs, dist/build/Database/HDBC/MySQL/Connection.o ) [2 of 3] Compiling Database.HDBC.MySQL.RTS ( dist/build/Database/HDBC/MySQL/RTS.hs, dist/build/Database/HDBC/MySQL/RTS.o ) [3 of 3] Compiling Database.HDBC.MySQL ( Database/HDBC/MySQL.hs, dist/build/Database/HDBC/MySQL.o ) ignoring (possibly broken) abi-depends field for packages Installing library in /home/mattei/.cabal/lib/x86_64-linux-ghc-8.4.3/HDBC-mysql-0.7.1.0-AJdQSgPQTaiJhYiidzdzS0 Installed HDBC-mysql-0.7.1.0
Output of
cabal build -v
aftercabal configure
:ldOptions:
includeDirs:
OS is FreeBSD 10.3 (amd64), and GHC version is GHC 8.0.1.
Please let me know if you need more information.
Thanks in advance for looking