Results 1 to 3 of 3

Thread: Oneiric and indirect linking

  1. #1
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Beans
    415
    Distro
    Ubuntu Development Release

    Oneiric and indirect linking

    I'm at my wit's end trying to get Freeswitch (www.freeswitch.org) to compile on Oneiric.

    It fails to compile with errors such as:

    Code:
    ./libesl.a(esl_threadmutex.o): In function `esl_thread_create_detached_ex':
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:116: undefined reference to `pthread_attr_setstacksize'
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:118: undefined reference to `pthread_create'
    ./libesl.a(esl_threadmutex.o): In function `esl_mutex_create':
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:149: undefined reference to `pthread_mutexattr_init'
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:152: undefined reference to `pthread_mutexattr_settype'
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:161: undefined reference to `pthread_mutexattr_destroy'
    ./libesl.a(esl_threadmutex.o): In function `esl_mutex_trylock':
    /usr/src/freeswitch/libs/esl/src/esl_threadmutex.c:207: undefined reference to `pthread_mutex_trylock'
    ../../libs/libedit/src/.libs/libedit.a(term.o): In function `term_move_to_char':
    /usr/src/freeswitch/libs/libedit/src/term.c:650: undefined reference to `tgoto'
    /usr/src/freeswitch/libs/libedit/src/term.c:650: undefined reference to `tputs'
    ... and so on.

    It compiles fine on an up-to-date Debian Wheezy installation, so I figure it's got to be something fairly subtle in Oneiric's gcc/ld defaults.

    I tried compiling with CFLAGS=-Wl,--copy-dt-needed-entries,--no-as-needed to try to revert the behaviour described here https://wiki.ubuntu.com/NattyNarwhal...hainTransition but to no success.

    I had this problem on Natty during the beta phase too, and got around it by using gcc 4.4 instead of 4.5 (and later 4.6). After a while, I gave it a try with 4.6 again, and it was ok (I suspect when they must have reverted the --as-needed default).

    But with Oneiric, it just a big case of fail at the moment. What has Ubuntu done to gcc to make it so picky?

    Any help greatly appreciated.
    Last edited by pressureman; August 25th, 2011 at 10:01 PM.
    Linux user since Slackware 3.4

  2. #2
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Beans
    415
    Distro
    Ubuntu Development Release

    Re: Oneiric and indirect linking

    Nevermind, fixed it after changing order of libs passed to linker.
    Linux user since Slackware 3.4

  3. #3
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Oneiric and indirect linking

    just for future reference as this is a common problem:

    oneiric uses the linker flag --as-needed by default. With this flag correct ordering of libraries and objects on the commandline is important.
    objects needing symbols must be placed before libraries providing them.
    E.g. file.o and staticlib.a need symbols from libm:
    wrong:
    Code:
    gcc -lm file.o staticlib.a
    gcc will think libm is not needed and drops it, when it later encounters the objects needing it you will get undefined references
    right:
    Code:
    gcc file.o staticlib.a -lm
    Important for autotools makefiles. Place libraries into LIBS or LDADD variables, not in LDFLAGS

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •