我正在尝试安装 libspopc,但是当我运行 make 时我得到以下输出:
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c session.c
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c queries.c
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c parsing.c
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c format.c
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c objects.c
cc -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL -c libspopc.c
rm -f libspopc*.a
ar r libspopc-0.9n.a session.o queries.o parsing.o format.o objects.o libspopc.o
ar: creating libspopc-0.9n.a
ranlib libspopc-0.9n.a
ln -s libspopc-0.9n.a libspopc.a
rm -f libspopc*.so
cc -o libspopc-0.9n.so -shared session.o queries.o parsing.o format.o objects.o libspopc.o
ln -s libspopc-0.9n.so libspopc.so
cc -o poptest1 -Wall -Wextra -pedantic -pipe -fPIC -Os -DUSE_SSL examples/poptest1.c -L. -lspopc -lssl -lcrypto
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x2d): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x43): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x4d): undefined reference to `dlclose'
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x8f): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0xe9): undefined reference to `dlerror'
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x491): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x570): undefined reference to `dlerror'
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x5f1): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x6d0): undefined reference to `dlerror'
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x735): undefined reference to `dlclose'
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x817): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x88e): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x8d5): undefined reference to `dlerror'
collect2: ld returned 1 exit status
make: *** [poptest1] Error 1
快速搜索表明这是由于 libdl 未链接造成的,尽管这在分布式库中似乎不太可能,尤其是一个看似相对流行的库。还有其他原因导致这种情况吗?如果是由于未链接的库造成的,我该如何修复它?
谢谢
答案1
您没有明确要求在 Makefile 中链接libdl
。您应该尝试手动添加是否可以解决这个问题(是否自动添加可能取决于您的编译器)。
LDFLAGS+=-ldl
答案2
可以按照以下步骤解决上述问题。
- 使用命令解压此文件
tar -xf openssl-1.0.2-latest.tar.gz
export CFLAGS=-fPIC
./config shared --prefix=/your/path
make
make install