简体   繁体   中英

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

I am trying to compile libircclient with ssl enabled

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

But I get the error

undefined reference to `dlopen'

This is my build log

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$ 

It is quite clear that the sample program from the examples subdirectory is not getting linked with libdl. That link command makes it quite clear.

You explicitly set LDFLAGS in the environment to include the "-ldl" flag, before running configure , so the problem is that the makefile that's responsible for building this test program is not picking up the manual LDFLAGS setting.

So, really, that's what the problem is. Your next step is to try to figure out why, by yourself. Of course, you might get lucky and someone around here would be nice enough to grab this package themselves, and figure it out for you.

But, if you're actually looking to learn something from this experience, you should do it yourself. Go look at the actual makefile that builds it, see what command is used to link the program, what variables it's using, and then, figure out what needs to be done to make this part of this application link correctly.

This is an excellent opportunity for you to learn all about the GNU toolchain that's obviously used here: autoconf , automake , and libtool . And, once you do that, you'll be able to figure out and work with not just this particular software package, but with thousands and thousands of other free software packages that also use the GNU toolchain. I'm sure you will agree that this would be a very useful skill to have. It might take some time for you to read through all the documentation, understand it, and learn how to use it, but you'll be able to take this knowledge with you, and use it many times in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM