You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Diwaker Gupta (Created) (JIRA)" <ji...@apache.org> on 2012/03/28 22:47:31 UTC

[jira] [Created] (THRIFT-1547) Problems building against static libevent

Problems building against static libevent
-----------------------------------------

                 Key: THRIFT-1547
                 URL: https://issues.apache.org/jira/browse/THRIFT-1547
             Project: Thrift
          Issue Type: Bug
          Components: C++ - Library
    Affects Versions: 0.8
         Environment: Thrift trunk on Ubuntu 11.10
            Reporter: Diwaker Gupta
            Assignee: Jake Farrell
            Priority: Minor


We don't depend on the platform supplied libevent when building Thrift -- we point to our own build. Further, we build libevent statically, so there are no shared objects to link against.

Unfortunate, the Thrift configure scripts fail to detect libevent. There are two problems. First, when static linking libevent, it complains about missing references to clock_gettime etc. This is easily fixed by settings LIBS to '-lrt' when running 'configure'. Thrift still fails to detect libevent because of the second issue: even with -lrt available, 'configure' is not able to compile the levent test program. This is because the GNU linked ('ld') is sensitive to the order in which libraries are specified.

Specifically, libraries that depend on other libraries should appear first (see [1], [2]). The following patch fixes the problem:

{noformat}
diff --git aclocal/ax_lib_event.m4 aclocal/ax_lib_event.m4
index 91de828..2049444 100644
--- aclocal/ax_lib_event.m4
+++ aclocal/ax_lib_event.m4
@@ -59,7 +59,7 @@ AC_DEFUN([AX_LIB_EVENT_DO_CHECK],
           # Prepare the environment for compilation.
           CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
           LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
-          LIBS="$LIBS $LIBEVENT_LIBS"
+          LIBS="$LIBEVENT_LIBS $LIBS"
           export CPPFLAGS
           export LDFLAGS
           export LIBS
{noformat}

Note: this doesn't affect zlib because it doesn't have any dependencies on system libraries.

[1] http://stackoverflow.com/a/409470/852987
[2] http://www.network-theory.co.uk/docs/gccintro/gccintro_18.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira