簡體   English   中英

在啟用ssl的情況下構建libircclient時未定義對dlopen的引用

[英]undefined reference to `dlopen' when building libircclient with ssl enabled

我正在嘗試啟用ssl來編譯libircclient

export LDFLAGS="-Wl,--no-as-needed -ldl -L/usr/local/ssl/lib -lssl -lcrypto"
export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib
./configure --enable-openssl --enable-ipv6

但是我得到了錯誤

未定義對dlopen的引用

這是我的構建日志

user@nano:~/luaTest/thirdparty/libircclient-1.8$ export LDFLAGS="-ldl -L/usr/local/ssl/lib -lssl -lcrypto"
user@nano:~/luaTest/thirdparty/libircclient-1.8$ export CPATH=/usr/local/includeuser@nano:~/luaTest/thirdparty/libircclient-1.8$ export LIBRARY_PATH=/usr/local/lib
user@nano:~/luaTest/thirdparty/libircclient-1.8$ export LD_LIBRARY_PATH=/usr/local/lib
user@nano:~/luaTest/thirdparty/libircclient-1.8$ ./configure --enable-openssl --enable-ipv6
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for ar... ar
checking for ranlib... ranlib
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking whether lstat correctly handles trailing slash... yes
checking whether stat accepts an empty string... no
checking for localtime_r... yes
checking for socket... yes
checking for socket in -lsocket... no
checking for getaddrinfo... yes
checking for inet_pton... yes
checking for getaddrinfo in -lnsl... yes
checking For MinGW32... no
checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: OpenSSL not found
user@nano:~/luaTest/thirdparty/libircclient-1.8$ make
for subdir in src examples; do \
        make -C $subdir || exit 1; \
    done
make[1]: Entering directory `/home/user/luaTest/thirdparty/libircclient-1.8/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/user/luaTest/thirdparty/libircclient-1.8/src'
make[1]: Entering directory `/home/user/luaTest/thirdparty/libircclient-1.8/examples'
gcc -o spammer spammer.o -L../src/ -lircclient -lpthread -lssl -lcrypto  -lnsl
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x15): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x2b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x35): undefined reference to `dlclose'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x33b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x410): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x48b): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x566): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x5e0): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x658): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x69d): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x736): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x821): undefined reference to `dlerror'
/usr/local/lib/../lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x87e): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make[1]: *** [spammer] Error 1
make[1]: Leaving directory `/home/user/luaTest/thirdparty/libircclient-1.8/examples'
make: *** [all] Error 1
user@nano:~/luaTest/thirdparty/libircclient-1.8$ 

很顯然, examples子目錄中的示例程序未與libdl鏈接。 該鏈接命令非常清楚。

在運行configure之前,您已在環境中將LDFLAGS顯式設置為包括“ -ldl”標志,因此問題在於負責構建此測試程序的makefile沒有采用手動LDFLAGS設置。

所以,實際上,這就是問題所在。 下一步是嘗試自己找出原因。 當然,您可能會很幸運,這里附近的某個人會很友善地自己拿起這個包裝,並為您解決。

但是,如果您實際上是想從這種經驗中學到東西,則應該自己做。 查看構建它的實際makefile,查看使用什么命令鏈接程序,使用什么變量,然后找出需要做些什么才能使該應用程序的這一部分正確鏈接。

這是一個絕佳的機會,讓您了解所有顯然在這里使用的GNU工具鏈: autoconfautomakelibtool 而且,一旦執行了此操作,您不僅可以弄清楚並使用這個特定的軟件包,還可以使用成千上萬個也使用GNU工具鏈的其他免費軟件包。 我相信您會同意這是一項非常有用的技能。 您可能需要花費一些時間來閱讀,理解和學習所有文檔,但是您將能夠隨身攜帶這些知識,並在將來多次使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM