Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1547

Problems building against static libevent

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 0.8
    • Fix Version/s: 0.10.0
    • Component/s: C++ - Library
    • Labels:
      None
    • Environment:

      Thrift trunk on Ubuntu 11.10

    • Patch Info:
      Patch Available

      Description

      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:

      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
      

      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

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              diwaker Diwaker Gupta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: