Skip to contentSkip to conversation

rabbitmq-c: link against zlib and libintl

PATCH Superseded Joris Lijssens 2 participants 4 messages Jan 28, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rabbitmq-c: link against zlib and libintl

When building the amqp toolset and static linking is enabled, the rabbitmq-c library needs to explicity link against zlib and libintl

Fixes:
http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/

---
 ...bintl-are-needed-when-the-rabbitmq-toolse.patch | 87 ++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch
package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch new file +87 -0
new file mode 100644
index 0000000..35facea
@@ -0,0 +1,87 @@
+From 208bc5adb10c73add19abb70f204951d1ef1b8b8 Mon Sep 17 00:00:00 2001
+From: Joris Lijssens <[email protected]>
+Date: Thu, 28 Jan 2016 09:14:24 +0100
+Subject: [PATCH] Zlib and libintl are needed when the rabbitmq toolset is
+ staticaly linked
+
+Signed-off-by: Joris Lijssens <[email protected]>
+---
+ CMakeLists.txt             | 11 +++++++++++
+ librabbitmq/CMakeLists.txt |  2 +-
+ tools/CMakeLists.txt       | 10 +++++-----
+ 3 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9b40a37..c9b1113 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -71,6 +71,7 @@ else()
+   endif()
+ endif()
+ 
++
+ # Detect if we need to link against a socket library:
+ cmake_push_check_state()
+ if (WIN32)
+@@ -263,6 +264,16 @@ option(BUILD_API_DOCS "Build Doxygen API docs" ${DOXYGEN_FOUND})
+ option(ENABLE_SSL_SUPPORT "Enable SSL support" ON)
+ option(ENABLE_THREAD_SAFETY "Enable thread safety when using OpenSSL" ${Threads_FOUND})
+ 
++
++# Zlib and libintl are needed for the static linking of tools
++if (BUILD_STATIC_LIBS)
++  set(ZLIB_LIBRARY "z")
++  set(INTL_LIBRARY "intl")
++else ()
++  set(ZLIB_LIBRARY "")
++  set(INTL_LIBRARY "")
++endif()
++  
+ set(SSL_ENGINE "OpenSSL" CACHE STRING "SSL Backend to use, valid options: OpenSSL, cyaSSL, GnuTLS, PolarSSL")
+ mark_as_advanced(SSL_ENGINE)
+ 
+diff --git a/librabbitmq/CMakeLists.txt b/librabbitmq/CMakeLists.txt
+index 3c86094..46594f3 100644
+--- a/librabbitmq/CMakeLists.txt
++++ b/librabbitmq/CMakeLists.txt
+@@ -87,7 +87,7 @@ if (ENABLE_SSL_SUPPORT)
+         amqp_hostcheck.h
+     )
+     include_directories(${OPENSSL_INCLUDE_DIR})
+-    set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES})
++    set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARY})
+     if (APPLE)
+       # Apple has deprecated OpenSSL in 10.7+. This disables that warning.
+       set_source_files_properties(${AMQP_SSL_SRCS}
+diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
+index 52e3464..8658ea7 100644
+--- a/tools/CMakeLists.txt
++++ b/tools/CMakeLists.txt
+@@ -19,19 +19,19 @@ set(COMMON_SRCS
+     )
+ 
+ add_executable(amqp-publish publish.c ${COMMON_SRCS})
+-target_link_libraries(amqp-publish ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-publish ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-get get.c ${COMMON_SRCS})
+-target_link_libraries(amqp-get ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-get ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-consume consume.c ${PLATFORM_DIR}/process.c ${COMMON_SRCS})
+-target_link_libraries(amqp-consume ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-consume ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-declare-queue declare_queue.c ${COMMON_SRCS})
+-target_link_libraries(amqp-declare-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-declare-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-delete-queue delete_queue.c ${COMMON_SRCS})
+-target_link_libraries(amqp-delete-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-delete-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ if (BUILD_TOOLS_DOCS)
+   if (XMLTO_FOUND)
+-- 
+1.8.3.1
+
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 rabbitmq-c: link against zlib and libintl

Dear Joris Lijssens,

Quoted 6 lines · Joris Lijssens

When building the amqp toolset and static linking is enabled, the rabbitmq-c library needs to explicity link against zlib and libintl

Fixes:
http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/

Hum, I think I already reviewed a similar patch, and said it wasn't correct, so I still stand on my position that it isn't correct.

If you look at the failure at
http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/build-end.log,
rabbitmq-c is *NOT* using zlib or libintl.

What you are seeing is that:

* libcrypto is using zlib
* libpopt is using libintl

So rabbitmq-c should *NOT* be changed to link against zlib or libintl. It should be changed to query OpenSSL (which provides libcrypto) and popt to know against which libraries to link to use OpenSSL and popt.

See my previous answer on the matter on:

Subject: Re: [Buildroot] [PATCH] rabbitmq-c: link against zlib and libintl
Date: Wed, 20 Jan 2016 10:41:56 +0100

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v2 1/1 rabbitmq-c: link against zlib and libintl

Hello Thomas,

I know that libcrypto is using zlib and libpopt is using libintl, but i have no idea how to query opensll and popt in cmake. Can you give some pointers?

regards,
Joris

Quoted 34 lines · Thomas Petazzoni

Dear Joris Lijssens,

Quoted 5 lines · Joris Lijssens

When building the amqp toolset and static linking is enabled, the rabbitmq-c library needs to explicity link against zlib and libintl

Fixes:

http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/

Quoted 1 line

Hum, I think I already reviewed a similar patch, and said it wasn't correct, so I still stand on my position that it isn't correct.

If you look at the failure at

http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/build-end.log
,
rabbitmq-c is *NOT* using zlib or libintl.

What you are seeing is that:

* libcrypto is using zlib
* libpopt is using libintl

So rabbitmq-c should *NOT* be changed to link against zlib or libintl. It should be changed to query OpenSSL (which provides libcrypto) and popt to know against which libraries to link to use OpenSSL and popt.

See my previous answer on the matter on:

Subject: Re: [Buildroot] [PATCH] rabbitmq-c: link against zlib and libintl
Date: Wed, 20 Jan 2016 10:41:56 +0100

Quoted 8 lines

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160128/2f82d3f0/attachment.html>

#3 lore raw

PATCH v2 1/1 rabbitmq-c: link against zlib and libintl

Joris,

(Please don't top post, this is considered bad practice on most mailing list.)

I'm adding Samuel Martin in Cc, he is our CMake expert :)

Quoted 3 lines · Joris Lijssens

I know that libcrypto is using zlib and libpopt is using libintl, but i have no idea how to query opensll and popt in cmake. Can you give some pointers?

So, for the libcrypto -> zlib case, I had a look. rabbitmq-c properly uses find_package(OpenSSL), which uses pkg-config internally, and there knows about the -lz dependency. Building the rabbitmq-c library (in the librabbitmq/ directory) works fine.

However, the problem occurs when linking the tools (in the tools/ directory): they are linked against the librabbitmq library. They know that they should link with -lssl -lcrypto (and I couldn't figure out how) but they don't know they should link with -lz.

Samuel, what is the usual solution for such situations with CMake ?

If you want to reproduce by yourself, here is a minimal defconfig:

BR2_arm=y
BR2_STATIC_LIBS=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-static-2015.11-rc1-71-g90d1299.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_14=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_OPENSSL=y
BR2_PACKAGE_RABBITMQ_C=y
BR2_PACKAGE_POPT=y
# BR2_TARGET_ROOTFS_TAR is not set

(This one produces only the libcrypto -> zlib problem. To produce the popt problem, you need to add BR2_PACKAGE_GETTEXT=y).

The popt problem is exactly the same: pkg-config is used to detect popt, popt.pc contains -lintl, but it isn't used when linking the tools.

Samuel, help :-)

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com