[Maria-discuss] mariadb 10 build/link ignores specified linker path to specified lib (pcre). correct method?
building mariadb 10.0.15 on linux/64 i have a non-system instance of (lib)pcre, installed in /usr/local/test/pcre, that i need to build/link against reading Link MariaDB Client Library for C with specific external zlib and openssl https://mariadb.com/kb/en/mariadb/client-libraries/client-library-for-c/link... i've built with cmake .. \ ... -DCMAKE_C_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_CXX_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="... -L/usr/local/test/pcre/lib64 -lpcre" \ ... and cmake .. \ ... -DCMAKE_C_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_CXX_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="... -L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64 -lpcre " \ ... but id both cases, the resultant binary still links against system pcre libs ldd sql/mysqld | egrep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f6165a5e000) what's the correct method for linking against a specified, non-system path'd lib? specifically, here, libpcre?
--On Wednesday, December 10, 2014 7:59 AM -0800 grantksupport@operamail.com wrote:
building mariadb 10.0.15 on linux/64
i have a non-system instance of (lib)pcre, installed in /usr/local/test/pcre, that i need to build/link against
reading
Link MariaDB Client Library for C with specific external zlib and openssl
https://mariadb.com/kb/en/mariadb/client-libraries/client-library-for-c/l ink-mariadb-client-library-for-c-with-specific-external-zlib-and-openssl/
Hi Grant, I don't know if this will help, but this is what I had to do to get MariaDB to link to Zimbra's OpenSSL in /opt/zimbra: CPPFLAGS="-I/opt/zimbra/openssl-$(OPENSSL_VERSION)/include" \ /usr/bin/cmake . -DCMAKE_SKIP_BUILD_RPATH=FALSE \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE \ -DCMAKE_INSTALL_RPATH="/opt/zimbra/openssl-$(OPENSSL_VERSION)/lib" \ -DCMAKE_PREFIX_PATH=/opt/zimbra/openssl-$(OPENSSL_VERSION) -DWITH_SSL=yes \ --Quanah -- Quanah Gibson-Mount Platform Architect Zimbra, Inc. -------------------- Zimbra :: the leader in open source messaging and collaboration
On Wed, Dec 10, 2014, at 10:38 AM, Quanah Gibson-Mount wrote:
I don't know if this will help, but this is what I had to do to get MariaDB to link to Zimbra's OpenSSL in /opt/zimbra:
(...) There are SSL-specific flags in the MariaDB cmake build. This is the method, from a colleague, for rpath-linking SSL libs in MariaDB, with openssl in /usr/local/ssl/, cmake .. \ ... -G "Unix Makefiles" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_SKIP_BUILD_RPATH=0 \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=0 \ -DCMAKE_INSTALL_RPATH="" \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DWITH_MYSQLD_LDFLAGS="-L/usr/local/ssl/lib64 -Wl,-rpath,/usr/local/ssl/lib64 -lssl -lcrypto " \ -DWITH_SSL=/usr/local/ssl \ -DOPENSSL_ROOT_DIR=/usr/local/ssl \ -DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include \ -DOPENSSL_LIBRARIES=/usr/local/ssl/lib64/libssl.so \ -DCRYPTO_LIBRARY=/usr/local/ssl/lib64/libcrypto.so \ ... It works here as expected; and has survived all builds in 10-branch. ldd sql/mysqld | egrep -i "ssl|crypto|pcre" libssl.so.1.0.0 => /usr/local/ssl/lib64/libssl.so.1.0.0 (0x00007f616673d000) libcrypto.so.1.0.0 => /usr/local/ssl/lib64/libcrypto.so.1.0.0 (0x00007f6166343000) Afaict, there are NOT pcre-specific flags available. I'll try a variant of your approach above for pcre ...
--On Wednesday, December 10, 2014 12:07 PM -0800 grantksupport@operamail.com wrote:
On Wed, Dec 10, 2014, at 10:38 AM, Quanah Gibson-Mount wrote:
I don't know if this will help, but this is what I had to do to get MariaDB to link to Zimbra's OpenSSL in /opt/zimbra:
(...)
There are SSL-specific flags in the MariaDB cmake build.
This is the method, from a colleague, for rpath-linking SSL libs in MariaDB, with openssl in /usr/local/ssl/,
Ugh, seems unnecessarily complicated vs my solution, which works just fine. ;) I'll play around with it however. Thanks for the pointer. --Quanah -- Quanah Gibson-Mount Platform Architect Zimbra, Inc. -------------------- Zimbra :: the leader in open source messaging and collaboration
I'll try a variant of your approach above ...
CPPFLAGS="-I/usr/local/pcre/include" \ cmake .. \ ... -G "Unix Makefiles" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_SKIP_BUILD_RPATH=0 \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=0 \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DCMAKE_INSTALL_RPATH="/usr/local/pcre/lib64" \ ... make still results in ldd sql/mysqld | grep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f034bb38000) prefixing with LDFLAGS="-L/usr/local/pcre/lib64 -Wl,-rpath,/usr/local/pcre/lib64 -lpcre" \ for good measure also makes not difference; the system libs are incorrectly linked.
Hi! On Dec 10, grantksupport@operamail.com wrote:
building mariadb 10.0.15 on linux/64
i have a non-system instance of (lib)pcre, installed in /usr/local/test/pcre, that i need to build/link against ... cmake .. \ ... -DCMAKE_C_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_CXX_FLAGS="... -I/usr/local/test/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="... -L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64 -lpcre" \ ...
but id both cases, the resultant binary still links against system pcre libs
ldd sql/mysqld | egrep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f6165a5e000)
what's the correct method for linking against a specified, non-system path'd lib? specifically, here, libpcre?
Your command is almost correct. You only need to set CMAKE_EXE_LINKER_FLAGS, because CMAKE_SHARED_LINKER_FLAGS is used for linking shared libraries. Or you need to set both if you plan to use a shared library that needs pcre (like ha_mroonga.so or libmysqld.so). And you don't need to specify -lpcre, cmake adds it automatically and as necessary. Regards, Sergei
On Sat, Dec 13, 2014, at 12:45 PM, Sergei Golubchik wrote:
Your command is almost correct. You only need to set CMAKE_EXE_LINKER_FLAGS, because CMAKE_SHARED_LINKER_FLAGS is used for linking shared libraries.
Or you need to set both if you plan to use a shared library that needs pcre (like ha_mroonga.so or libmysqld.so).
And you don't need to specify -lpcre, cmake adds it automatically and as necessary.
building with cmake .. \ ... -DWITH_PCRE="auto" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_SKIP_BUILD_RPATH=0 \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=0 \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DCMAKE_INSTALL_RPATH="/usr/local/pcre/lib64" \ -DCMAKE_C_FLAGS="-I/usr/local/test/pcre/includes" \ -DCMAKE_CXX_FLAGS="-I/usr/local/test/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="-L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64" \ -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64" \ ... make still results in ldd sql/mysqld | egrep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f5153b76000) something else missing? need changing?
fyi, adding + CPPFLAGS="-I/usr/local/pcre/include" \ + LDFLAGS="-L/usr/local/pcre/lib64 -Wl,-rpath,/usr/local/pcre/lib64 -lpcre" \ cmake .. \ ... -DWITH_PCRE="auto" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_SKIP_BUILD_RPATH=0 \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=0 \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DCMAKE_INSTALL_RPATH="/usr/local/pcre/lib64" \ -DCMAKE_C_FLAGS="-I/usr/local/pcre/includes" \ -DCMAKE_CXX_FLAGS="-I/usr/local/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="-L/usr/local/pcre/lib64 -Wl,-rpath,/usr/local/pcre/lib64" \ -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/pcre/lib64 -Wl,-rpath,/usr/local/pcre/lib64" \ ... make doesn't make a difference. still, ldd sql/mysqld | egrep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f5153b76000)
Hi, grantksupport! On Dec 13, grantksupport@operamail.com wrote:
On Sat, Dec 13, 2014, at 12:45 PM, Sergei Golubchik wrote:
Your command is almost correct. You only need to set CMAKE_EXE_LINKER_FLAGS, because CMAKE_SHARED_LINKER_FLAGS is used for linking shared libraries.
Or you need to set both if you plan to use a shared library that needs pcre (like ha_mroonga.so or libmysqld.so).
And you don't need to specify -lpcre, cmake adds it automatically and as necessary.
building with
cmake .. \ ... -DWITH_PCRE="auto" \ -DBUILD_SHARED_LIBS=1 \ -DCMAKE_SKIP_BUILD_RPATH=0 \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=0 \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1 \ -DCMAKE_INSTALL_RPATH="/usr/local/pcre/lib64" \ -DCMAKE_C_FLAGS="-I/usr/local/test/pcre/includes" \ -DCMAKE_CXX_FLAGS="-I/usr/local/test/pcre/includes" \ -DCMAKE_SHARED_LINKER_FLAGS="-L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64" \ -DCMAKE_EXE_LINKER_FLAGS="-L/usr/local/test/pcre/lib64 -Wl,-rpath,/usr/local/test/pcre/lib64" \ ... make
still results in
ldd sql/mysqld | egrep -i "pcre" libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f5153b76000)
something else missing? need changing?
Perhaps you're specifying all possible options and they affect each other. I didn't try all that, I only used cmake .. -DCMAKE_C_FLAGS="-I$HOME/pcre-local/include" \ -DCMAKE_CXX_FLAGS="-I$HOME/pcre-local/include" \ -DCMAKE_EXE_LINKER_FLAGS="-L$HOME/pcre-local/lib -Wl,-rpath,$HOME/pcre-local/lib" and that worked for me. Regards, Sergei
participants (3)
-
grantksupport@operamail.com
-
Quanah Gibson-Mount
-
Sergei Golubchik