2014-06-12 34 views
0

由於某種原因,我在這個特定的C++文件中獲取了MD5和RAND_bytes的未定義符號。 OpenSSL已將自己(libssl和libcrypto)安裝到/ usr/lib和/ usr/include/openssl /。Autotools和OpenSSL MD5/RAND_bytes undefined

libtool: link: (cd ".libs" && rm -f "libeapgpsk.so.1" && ln -s "libeapgpsk.so.1.0.0" "libeapgpsk.so.1") 
libtool: link: (cd ".libs" && rm -f "libeapgpsk.so" && ln -s "libeapgpsk.so.1.0.0" "libeapgpsk.so") 
libtool: link: ar cru .libs/libeapgpsk.a eap-gpsk/eap_gpsk_fsm.o 
libtool: link: ranlib .libs/libeapgpsk.a 
libtool: link: (cd ".libs" && rm -f "libeapgpsk.la" && ln -s "../libeapgpsk.la" "libeapgpsk.la") 
depbase=`echo tests/md5_test.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ 
    g++ -DPACKAGE_NAME=\"OpenDiameter\" -DPACKAGE_TARNAME=\"opendiameter\" -DPACKAGE_VERSION=\"1.0.7-i\" -DPACKAGE_STRING=\"OpenDiameter\ 1.0.7-i\" -DPACKAGE_BUGREPORT=\"[email protected]\" -DPACKAGE_URL=\"\" -DPACKAGE=\"opendiameter\" -DVERSION=\"1.0.7-i\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_IFADDRS_H=1 -DHAVE_SHADOW_H=1 -DHAVE__BOOL=1 -DHAVE_STDBOOL_H=1 -DHAVE_GETIFADDRS=1 -I. -Wall -I/usr -I/usr -fno-strict-aliasing -I../include -I../libeap/include -DOS_LINUX -I/usr/include/openssl -I/usr/include/openssl -MT tests/md5_test.o -MD -MP -MF $depbase.Tpo -c -o tests/md5_test.o tests/md5_test.cxx &&\ 
    mv -f $depbase.Tpo $depbase.Po 
In file included from ../include/aaa_dictionary_api.h:45:0, 
       from ../include/aaa_parser_api.h:38, 
       from ../libeap/include/eap.hxx:54, 
       from tests/md5_test.cxx:45: 
../include/framework.h:1653:7: warning: ‘typedef’ was ignored in this declaration [enabled by default] 
In file included from ../include/aaa_parser_api.h:38:0, 
       from ../libeap/include/eap.hxx:54, 
       from tests/md5_test.cxx:45: 
../include/aaa_dictionary_api.h:58:1: warning: ‘typedef’ was ignored in this declaration [enabled by default] 
tests/md5_test.cxx: In constructor ‘EapTask::EapTask()’: 
tests/md5_test.cxx:71:45: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] 
tests/md5_test.cxx: In constructor ‘PeerApplication::PeerApplication(EapTask&, ACE_Semaphore&)’: 
tests/md5_test.cxx:418:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] 
tests/md5_test.cxx: In constructor ‘StandAloneAuthApplication::StandAloneAuthApplication(EapTask&, ACE_Semaphore&)’: 
tests/md5_test.cxx:460:80: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] 
tests/md5_test.cxx: In constructor ‘BackendAuthApplication::BackendAuthApplication(EapTask&, ACE_Semaphore&, bool)’: 
tests/md5_test.cxx:514:58: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] 
tests/md5_test.cxx: In constructor ‘PassThroughAuthApplication::PassThroughAuthApplication(EapTask&, ACE_Semaphore&, bool)’: 
tests/md5_test.cxx:576:62: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] 
/bin/bash ../libtool --tag=CXX --mode=link g++ -I/usr/include/openssl -L/usr/lib -o md5_test tests/md5_test.o -ldl -lssl -lcrypto -lACE_SSL -lACE -lACEXML_Parser -lACEXML -lpthread -lboost_system -lboost_thread -lboost_system -lboost_thread -lACEXML -lACEXML_Parser -ldl -lssl -lcrypto ../libeap/libeap.la ../libeap/libeaparchie.la ../libeap/libeapgpsk.la -lboost_system -lboost_thread -lACEXML -lACEXML_Parser -ldl -lssl -lcrypto 
libtool: link: g++ -I/usr/include/openssl -o .libs/md5_test tests/md5_test.o -L/usr/lib /usr/lib/libACE_SSL.so /usr/lib/libACE.so -lpthread ../libeap/.libs/libeap.so ../libeap/.libs/libeaparchie.so ../libeap/.libs/libeapgpsk.so -lboost_system -lboost_thread /usr/lib/libACEXML.so /usr/lib/libACEXML_Parser.so -ldl -lssl -lcrypto 
../libeap/.libs/libeap.so: undefined reference to `[email protected]_1.0.0' 
../libeap/.libs/libeap.so: undefined reference to `[email protected]_1.0.0' 
collect2: ld returned 1 exit status 

這裏是Makefile.am負責此:

## Process this file with automake to produce Makefile.in 

srcdir = @[email protected] 
VPATH = @[email protected] 

AM_CPPFLAGS = @[email protected] \ 
       [email protected][email protected]/include \ 
       [email protected][email protected]/libeap/include \ 
       [email protected][email protected] 
AM_LDFLAGS = @[email protected] 

if compile_EAPTLS 
CORE_SRC = eapcore/eap_fsm.cxx \ 
    eapcore/eap_peerfsm.cxx \ 
    eapcore/eap_authfsm.cxx \ 
     eapcore/eap_standalone_authfsm.cxx \ 
     eapcore/eap_backend_authfsm.cxx \ 
     eapcore/eap_passthrough_authfsm.cxx \ 
    eapcore/eap_identity.cxx \ 
    eapcore/eap_method_registrar.cxx \ 
    eapcore/eap_policy.cxx \ 
     eapcore/eap_notification.cxx \ 
    eapcore/eap_md5.cxx 

CORE_HDR = include/eap_api.h \ 
     include/eap.hxx \ 
     include/eap_authfsm.hxx \ 
     include/eap_fsm.hxx \ 
     include/eap_identity.hxx \ 
     include/eap_log.hxx \ 
     include/eap_md5.hxx \ 
     include/eap_method_registrar.hxx \ 
     include/eap_notification.hxx \ 
     include/eap_parser.hxx \ 
     include/eap_peerfsm.hxx \ 
     include/eap_policy.hxx \ 
    include/eap_archie_crypto.hxx \ 
    include/eap_archie_fsm.hxx \ 
    include/eap_archie_parser.hxx \ 
    include/eap_archie.hxx \ 
    include/eap_gpsk_crypto.hxx \ 
    include/eap_gpsk_fsm.hxx \ 
    include/eap_gpsk_parser.hxx \ 
    include/eap_gpsk.hxx \ 
    include/eap_tls.hxx \ 
    include/eap_tls_mng.hxx \ 
    include/eap_tls_session.hxx \ 
    include/eap_tls_parser.hxx \ 
    include/eap_tls_fsm.hxx \ 
    include/eap_tls_xml_data.hxx \ 
    include/eap_tls_xml_parser.hxx \ 
    include/eap_tls_data_defs.hxx 
else 
CORE_SRC = eapcore/eap_fsm.cxx \ 
    eapcore/eap_peerfsm.cxx \ 
    eapcore/eap_authfsm.cxx \ 
     eapcore/eap_standalone_authfsm.cxx \ 
     eapcore/eap_backend_authfsm.cxx \ 
     eapcore/eap_passthrough_authfsm.cxx \ 
    eapcore/eap_identity.cxx \ 
    eapcore/eap_method_registrar.cxx \ 
    eapcore/eap_policy.cxx \ 
     eapcore/eap_notification.cxx \ 
    eapcore/eap_md5.cxx 

CORE_HDR = include/eap_api.h \ 
     include/eap.hxx \ 
     include/eap_authfsm.hxx \ 
     include/eap_fsm.hxx \ 
     include/eap_identity.hxx \ 
     include/eap_log.hxx \ 
     include/eap_md5.hxx \ 
     include/eap_method_registrar.hxx \ 
     include/eap_notification.hxx \ 
     include/eap_parser.hxx \ 
     include/eap_peerfsm.hxx \ 
     include/eap_policy.hxx \ 
    include/eap_archie_crypto.hxx \ 
    include/eap_archie_fsm.hxx \ 
    include/eap_archie_parser.hxx \ 
    include/eap_archie.hxx \ 
    include/eap_gpsk_crypto.hxx \ 
    include/eap_gpsk_fsm.hxx \ 
    include/eap_gpsk_parser.hxx \ 
    include/eap_gpsk.hxx 
endif 

ARCHIE_SRC = eap-archie/eap_archie_fsm.cxx 

GPSK_SRC = eap-gpsk/eap_gpsk_fsm.cxx 

if compile_EAPTLS 
TLS_SRC = eap-tls/eap_tls_mng.cxx \ 
      eap-tls/eap_tls_crypto.cxx \ 
      eap-tls/eap_tls_fsm.cxx \ 
      eap-tls/eap_tls_xml_data.cxx \ 
      eap-tls/eap_tls_xml_parser.cxx 
endif 

includedir = $(prefix)/include/opendiameter/eap 
include_HEADERS = $(CORE_HDR) 

sysconfdir = $(prefix)/etc/opendiameter/eap 
sysconf_DATA = config/client.eap-tls.xml \ 
       config/server.eap-tls.xml 

if compile_EAPTLS 
lib_LTLIBRARIES = libeap.la libeaparchie.la libeapgpsk.la libeaptls.la 
else 
lib_LTLIBRARIES = libeap.la libeaparchie.la libeapgpsk.la 
endif 

libeap_la_SOURCES = $(CORE_SRC) $(CORE_HDR) 
libeaparchie_la_SOURCES = $(ARCHIE_SRC) 
libeapgpsk_la_SOURCES = $(GPSK_SRC) 

if compile_EAPTLS 
libeaptls_la_SOURCES = $(TLS_SRC) 
endif 

libeap_la_LIBADD = -ldl -lssl -lcrypto 
libeap_la_LDFLAGS = -version-info 1:0:0 -lssl -lcrypto 
libeap_la_AR = $(AR) -qcs 

libeaparchie_la_LDFLAGS = -version-info 1:0:0 
libeaparchie_la_AR = $(AR) -qcs 

libeapgpsk_la_LDFLAGS = -version-info 1:0:0 
libeapgpsk_la_AR = $(AR) -qcs 

if compile_EAPTLS 
libeaptls_la_LDFLAGS = -version-info 1:0:0 
libeaptls_la_AR = $(AR) -qcs 
LDADD = @[email protected] \ 
     $(top_builddir)/libeap/libeap.la \ 
     $(top_builddir)/libeap/libeaparchie.la \ 
     $(top_builddir)/libeap/libeapgpsk.la \ 
     $(top_builddir)/libeap/libeaptls.la \ 
     $(top_builddir)/libdiamparser/libdiamparser.la 
else 
LDADD = @[email protected] \ 
     $(top_builddir)/libeap/libeap.la \ 
     $(top_builddir)/libeap/libeaparchie.la \ 
     $(top_builddir)/libeap/libeapgpsk.la 
endif 

if compile_EAPTLS 
noinst_PROGRAMS = md5_test archie_test gpsk_test tls_test 
else 
noinst_PROGRAMS = md5_test archie_test gpsk_test 
endif 

md5_test_SOURCES = tests/md5_test.cxx -lssl -lcrypto 

archie_test_SOURCES = tests/archie_test.cxx 

gpsk_test_SOURCES = tests/gpsk_test.cxx 

if compile_EAPTLS 
tls_test_SOURCES = tests/tls_test.cxx 
endif 

EXTRA_DIST = config 

我懷疑,因爲我沒有指定它這樣做自動工具是沒有做什麼。在文件md5_test.c裏面,但仍然有錯誤。

#include <openssl/md5.h> 
#include <openssl/rand.h> 

任何幫助將不勝感激。

編輯︰ 我挖入庫,看看是否有版本信息,它導致我這個非常有趣的困境 - openssl 1.0.0m編譯時使用此命令:./config --prefix =/usr - openssldir = /等/ SSL --libdir = LIB共享

產生兩組共享對象的位於:

/usr/lib/x86_64-linux-gnu/ 
/usr/lib 

共享對象在/ usr/LIB/x86_64的-Linux的GNU /產生一個版本(used objdump -T)

00000000001546b0 g DF .text 0000000000000108 OPENSSL_1.0.0 PKCS7_to_TS_TST_INFO 

在/ usr/lib中產生共享對象是:

000000000012ee20 g DF .text 000000000000000c Base  BIO_new_CMS 

如何將一個解決這個問題,因爲這似乎非常不規範....?

+0

您的'-lssl'是否找到不包含版本1.0.0符號(例如'MD5 @ OPENSSL_1.0.0')的'libssl'的舊版本? – twalberg

+0

我有openssl 1.0.0m編譯和安裝,所以我會這樣認爲:rbrash @ megatron:〜/ Downloads/diameter-svn/cplusplus $ sudo nm -D /usr/lib/libcrypto.so | grep md5 00000000000db570 T EVP_md5 0000000000067c30 T md5_block_asm_data_order rbrash @ megatron:〜/ Downloads/diameter-svn/cplusplus $ sudo nm -D /usr/lib/libcrypto.so | grep的MD5 0000000000067bb0牛逼MD5 00000000000679d0牛逼MD5_Final 0000000000067b00牛逼MD5_Init 00000000000679c0牛逼MD5_Transform 00000000000677a0牛逼MD5_Update – mcdoomington

回答

3

LDFLAGS中刪除-lssl -lcrypto爲您的圖書館;鏈接編輯器工作的方式,LDFLAGS在對象文件之前傳遞,這意味着它們被丟棄;至少在某些版本的鏈接編輯器中,在對象文件之前傳遞的庫也被「列入黑名單」,或者確切地說,它們在再次傳遞時會被忽略。

您在LDFLAGSLIBADD中都通過-lssl -lcrypto兩次,因此您可能會觸發該行爲。

+0

看來,你是正確的!謝謝! – mcdoomington