Find the answer to your Linux question:
Results 1 to 10 of 10
I am trying to compiling and create a library for one of my project. I got this error: Code: /usr/bin/ld: /tmp/ccI5dvjD.o: undefined reference to symbol 'dlopen@@GLIBC_2.1' /usr/bin/ld: note: 'dlopen@@GLIBC_2.1' is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26

    C code: link error.. need help


    I am trying to compiling and create a library for one of my project.
    I got this error:

    Code:
    /usr/bin/ld: /tmp/ccI5dvjD.o: undefined reference to symbol 'dlopen@@GLIBC_2.1'
    /usr/bin/ld: note: 'dlopen@@GLIBC_2.1' is defined in DSO /lib/libdl.so.2 so try adding it to the linker command line
    /lib/libdl.so.2: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[1]: ***
    I am not sure what does it mean. Can someone give me a suggestion?

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    Try adding "-ldl" (those are both lower-case letter "L"s there) at the end of your command-line. This instructs gcc to find a library called libdl.so, which contains the dlopen, dlsym etc. functions.

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26
    I got further and got this error:

    /usr/local/bin/ld: �: invalid DSO for symbol `pthread_setspecific@@GLIBC_2.0' definition
    /lib/libpthread.so.0: could not read symbols: Bad value
    collect2: ld returned 1 exit status

  4. #4
    Just Joined!
    Join Date
    Apr 2011
    Posts
    38
    Old topic, but I found the same problem compiling nufw in Fedora 14

    /usr/bin/ld: main.o: undefined reference to symbol 'pthread_create@@GLIBC_2.1'
    /usr/bin/ld: note: 'pthread_create@@GLIBC_2.1' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line
    /lib/libpthread.so.0: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[2]: *** [nufw] Error 1
    make[2]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nufw'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src'
    make: *** [all-recursive] Error 1
    I found out this is a common problem, but didn't find any solutions, any suggestions?

  5. #5
    Just Joined!
    Join Date
    May 2011
    Location
    Hyderabad, India
    Posts
    4
    Hi
    Please try to compile using the option -ldl and -lpthread. That should solve it.

    Regards
    Last edited by oz; 05-07-2011 at 12:40 PM. Reason: removed spam signature

  6. #6
    Just Joined!
    Join Date
    Apr 2011
    Posts
    38
    Unfortunatelly the problem persists...

  7. #7
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    Quote Originally Posted by eferre View Post
    Unfortunatelly the problem persists...
    Please post complete command + error message with the -ldl and -lpthread additions to the command-line.

  8. #8
    Just Joined!
    Join Date
    Apr 2011
    Posts
    38
    Here is the entire outcome:

    [root@eferre-fedora nufw-2.4.3]# make -ldl -lpthread
    Making all in src
    make[1]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src'
    Making all in include
    make[2]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/include'
    make all-am
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/include'
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/include'
    make[2]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/include'
    Making all in libs
    make[2]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs'
    Making all in nubase
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nubase'
    make[3]: Nothing to be done for `all'.
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nubase'
    Making all in nuconfparser
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nuconfparser'
    make all-am
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nuconfparser'
    make[4]: Nothing to be done for `all-am'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nuconfparser'
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nuconfparser'
    Making all in nussl
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nussl'
    make[3]: Nothing to be done for `all'.
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs/nussl'
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/libs'
    make[3]: Nothing to be done for `all-am'.
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs'
    make[2]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/libs'
    Making all in nuauth
    make[2]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth'
    Making all in modules
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules'
    Making all in ldap
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/ldap'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/ldap'
    Making all in log_syslog
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_syslog'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_syslog'
    Making all in log_script
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_script'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_script'
    Making all in log_mysql
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_mysql'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_mysql'
    Making all in log_pgsql
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_pgsql'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_pgsql'
    Making all in plaintext
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/plaintext'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/plaintext'
    Making all in system
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/system'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/system'
    Making all in xml_defs
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/xml_defs'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/xml_defs'
    Making all in x509_std
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/x509_std'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/x509_std'
    Making all in log_nuprelude
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_nuprelude'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_nuprelude'
    Making all in mark_uid
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_uid'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_uid'
    Making all in session_expire
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/session_expire'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/session_expire'
    Making all in ipauth_guest
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/ipauth_guest'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/ipauth_guest'
    Making all in mark_group
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_group'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_group'
    Making all in mark_field
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_field'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_field'
    Making all in mark_flag
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_flag'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/mark_flag'
    Making all in auth_mysql
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/auth_mysql'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/auth_mysql'
    Making all in session_authtype
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/session_authtype'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/session_authtype'
    Making all in log_ulogd2
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_ulogd2'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/log_ulogd2'
    Making all in postauth_localuser
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/postauth_localuser'
    make[4]: Nothing to be done for `all'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules/postauth_localuser'
    make[4]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules'
    make[4]: Nothing to be done for `all-am'.
    make[4]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules'
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth/modules'
    make[3]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth'
    make[3]: Nothing to be done for `all-am'.
    make[3]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth'
    make[2]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nuauth'
    Making all in nufw
    make[2]: Entering directory `/home/eferre/Downloads/nufw-2.4.3/src/nufw'
    /bin/sh ../../libtool --tag=CC --mode=link gcc -std=gnu99 -g -O2 -D_POSIX_C_SOURCE=199506L -D_ISOC99_SOURCE -D_GNU_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -Wextra -Wall -Wno-unused-parameter -O2 -lgcrypt -ldl -lgpg-error -o nufw authsrv.o common.o main.o packetsrv.o tls.o audit.o conntrack.o iface.o nufwconf.o -lnfnetlink -lnetfilter_queue ../libs/nussl/libnussl.la ../libs/nuconfparser/libnuconfparser.la ../libs/nubase/libnubase.la -L../../src/include/
    gcc -std=gnu99 -g -O2 -D_POSIX_C_SOURCE=199506L -D_ISOC99_SOURCE -D_GNU_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -Wextra -Wall -Wno-unused-parameter -O2 -o .libs/nufw authsrv.o common.o main.o packetsrv.o tls.o audit.o conntrack.o iface.o nufwconf.o -lnfnetlink -lnetfilter_queue ../libs/nussl/.libs/libnussl.so ../libs/nuconfparser/.libs/libnuconfparser.a ../libs/nubase/.libs/libnubase.a -lgcrypt -ldl -lgpg-error -L/home/eferre/Downloads/nufw-2.4.3/src/include -Wl,--rpath -Wl,/usr/local/lib
    /usr/bin/ld: main.o: undefined reference to symbol 'pthread_create@@GLIBC_2.1'
    /usr/bin/ld: note: 'pthread_create@@GLIBC_2.1' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line
    /lib/libpthread.so.0: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[2]: *** [nufw] Error 1
    make[2]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src/nufw'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/eferre/Downloads/nufw-2.4.3/src'
    make: *** [all-recursive] Error 1

  9. #9
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    152
    Quote Originally Posted by eferre View Post
    Code:
    # make -ldl -lpthread
    Ah, now that you've posted this, the problem becomes clear - you need to pass -lpthread to "gcc", not to "make" directly.

    Looks like you're using an autotools-generated makefile - easiest thing to do is to use CFLAGS to include -pthread (or -lpthread, but -pthread will do slightly more work on your behalf) - try the following command:

    Code:
    CFLAGS='-lpthread' make
    If that doesn't work, try reconfiguring like:

    Code:
    CFLAGS='-lpthread' ./configure --some-options-maybe
    and re"make"ing.

  10. #10
    Just Joined!
    Join Date
    Apr 2011
    Posts
    38
    Thank you! The second solution works!

Posting Permissions

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