[Maria-developers] linking an external library
Folks, I want to link an external library for a language extension. After several hours of trying to tell cmake (^%$@*&) to pick it up for linking the library would still not be built with. CMakeLists.txt in trunk/sql is in the meantime full of pointers to the library without avail. I did the normal FIND_LIBRARY() followed by TARGET_LINK_LIBRARIES({$LIBNAME}) on various targets plus as nothing worked: SET(CMAKE_LIBRARY_PATH) on it, explicity LINK_DIRECTORIES(), SET(CMAKE_PREFIX_PATH), SET(CMAKE_LIBRARY_PATH) ... How do I link mariadb with an external library?? Thanks Rob
rg <rgross854@gmail.com> writes:
I want to link an external library for a language extension. After several hours of trying to tell cmake (^%$@*&) to pick it up for linking the library would still not be built with.
did you remove the CMakeCache.txt file? CMake is garbage like that. -- Stewart Smith
TARGET_LINK_LIBRARIES({$LIBNAME}) is not a correct syntax It does need target (you link your library to some other library or executable, and this library or executable is called target) TARGET_LINK_LIBRARIES(<target> "${LIBNAME}") should work For example, if you want to link something with mysqld, you add to CMakeLists.txt TARGET_LINK_LIBRARIES(mysqld "${LIBNAME}") From: Maria-developers [mailto:maria-developers-bounces+wlad=montyprogram.com@lists.launchpad.net] On Behalf Of rg Sent: Montag, 19. August 2013 01:53 To: maria-developers@lists.launchpad.net Subject: [Maria-developers] linking an external library Folks, I want to link an external library for a language extension. After several hours of trying to tell cmake (^%$@*&) to pick it up for linking the library would still not be built with. CMakeLists.txt in trunk/sql is in the meantime full of pointers to the library without avail. I did the normal FIND_LIBRARY() followed by TARGET_LINK_LIBRARIES({$LIBNAME}) on various targets plus as nothing worked: SET(CMAKE_LIBRARY_PATH) on it, explicity LINK_DIRECTORIES(), SET(CMAKE_PREFIX_PATH), SET(CMAKE_LIBRARY_PATH) ... How do I link mariadb with an external library?? Thanks Rob
thanks for the tips so far and I can link external libs with e.g. libsql.a but the problem seems to go deeper and the core issue appears to be - linking a static library to say libsql.a breaks generation of libmysqld.a as Linux ar/ranlib can not strip out nested linked libraries. This is somewhat of a limitation and would cause quite some rewrite of things ready for integration (into libsql). Ouch. Rob On Mon, Aug 19, 2013 at 8:13 PM, Vladislav Vaintroub <wlad@montyprogram.com>wrote:
TARGET_LINK_LIBRARIES({$LIBNAME}) is not a correct syntax****
** **
It does need target (you link your library to some other library or executable, and this library or executable is called target)****
** **
TARGET_LINK_LIBRARIES(<target> “${LIBNAME}”) should work****
** **
For example, if you want to link something with mysqld, you add to CMakeLists.txt ****
TARGET_LINK_LIBRARIES(mysqld “${LIBNAME}”) ****
** **
** **
*From:* Maria-developers [mailto:maria-developers-bounces+wlad= montyprogram.com@lists.launchpad.net] *On Behalf Of *rg *Sent:* Montag, 19. August 2013 01:53 *To:* maria-developers@lists.launchpad.net *Subject:* [Maria-developers] linking an external library****
** **
Folks,****
I want to link an external library for a language extension. After several hours of trying to tell cmake (^%$@*&) to pick it up for linking the library would still not be built with.
CMakeLists.txt in trunk/sql is in the meantime full of pointers to the library without avail.****
I did the normal FIND_LIBRARY()****
followed by TARGET_LINK_LIBRARIES({$LIBNAME}) on various targets****
plus as nothing worked: SET(CMAKE_LIBRARY_PATH) on it, explicity LINK_DIRECTORIES(), SET(CMAKE_PREFIX_PATH), SET(CMAKE_LIBRARY_PATH) ... ** **
How do I link mariadb with an external library??****
Thanks Rob****
** **
** **
For embedded, "libsql.a" is not used. Instead, there is libsql_embedded.a, and it is built in libmysqld/CMakeLists.txt So, - If you want your static library to be "merged" into one big libmysqld.a , you need to add it into the LIBS list (see SET(LIBS.) in the CMakeLists.txt). - If you do not want it to be "merged", but still link correctly (make every executable that links with embedded link with your library) , add TARGET_LINK_LIBRARIES(mysqlserver ${LIBNAME}) , somewhere after MERGE_LIBRARIES , in libmysqld/CMakeLists.txt A work of caution : in case you static library $LIBNAME is built without PIC, the build of shared embedded library will fail (because in general case you cannot have non-PIC code in shared library).It is really much better to use external library as shared library (in this case you should use TARGET_LINK_LIBRARIES(mysqlserver ${LIBNAME}), somewhere after MERGE_LIBRARIES , in libmysqld/CMakeLists.txt ) From: rg [mailto:rgross854@gmail.com] Sent: Montag, 19. August 2013 20:00 To: Vladislav Vaintroub Cc: maria-developers@lists.launchpad.net Subject: Re: [Maria-developers] linking an external library thanks for the tips so far and I can link external libs with e.g. libsql.a but the problem seems to go deeper and the core issue appears to be - linking a static library to say libsql.a breaks generation of libmysqld.a as Linux ar/ranlib can not strip out nested linked libraries. This is somewhat of a limitation and would cause quite some rewrite of things ready for integration (into libsql). Ouch. Rob On Mon, Aug 19, 2013 at 8:13 PM, Vladislav Vaintroub < > wrote: TARGET_LINK_LIBRARIES({$LIBNAME}) is not a correct syntax It does need target (you link your library to some other library or executable, and this library or executable is called target) TARGET_LINK_LIBRARIES(<target> "${LIBNAME}") should work For example, if you want to link something with mysqld, you add to CMakeLists.txt TARGET_LINK_LIBRARIES(mysqld "${LIBNAME}") From: Maria-developers [mailto:maria-developers-bounces+wlad <mailto:maria-developers-bounces%2Bwlad> =montyprogram.com@lists.launchpad.net] On Behalf Of rg Sent: Montag, 19. August 2013 01:53 To: maria-developers@lists.launchpad.net Subject: [Maria-developers] linking an external library Folks, I want to link an external library for a language extension. After several hours of trying to tell cmake (^%$@*&) to pick it up for linking the library would still not be built with. CMakeLists.txt in trunk/sql is in the meantime full of pointers to the library without avail. I did the normal FIND_LIBRARY() followed by TARGET_LINK_LIBRARIES({$LIBNAME}) on various targets plus as nothing worked: SET(CMAKE_LIBRARY_PATH) on it, explicity LINK_DIRECTORIES(), SET(CMAKE_PREFIX_PATH), SET(CMAKE_LIBRARY_PATH) ... How do I link mariadb with an external library?? Thanks Rob
participants (3)
-
rg
-
Stewart Smith
-
Vladislav Vaintroub