c - 自 ubuntu 升级以来对 `dlopen' 的 undefined reference

标签 c ubuntu gcc

自从我升级到 ubuntu 13.10 和 gcc 4.8.1 后,我遇到了 undefined reference to `dlopen' 问题。

makefiles 已经工作了很多年。特定的调用是

gcc -rdynamic -o ov_dbutil ov_dbutil.o libov.so -ldl

错误是:

libov.so: undefined reference to `dlopen'
libov.so: undefined reference to `dlclose'
libov.so: undefined reference to `dlerror'
libov.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make: *** [ov_dbutil] Error 1

是不是gcc的问题?

ov_dbutil 使用以下行编译

gcc -g -Wall -O0 -shared -std=c99 -fno-strict-aliasing   -DPLT_SYSTEM_LINUX=1 -DPLT_USE_BUFFERED_STREAMS=1 -DPLT_SERVER_TRUNC_ONLY=1 -DNDEBUG   -DOV_SYSTEM_LINUX=1    -I../../../plt/include/ -I../../../ks/include/ -I../../include/ -I../../model/ -I../../source/codegen/ -I../../source/builder/ -I../../source/example/ -I../../source/kshist/ -I../../source/dynov/ -I../../source/tasklib/ -I../../source/dbparse/ -I../../source/dbdump/ -I../../../../libml/ -I../../include/runtimeserver/ -I. -c ../../source/dbutil/ov_dbutil.c -o ov_dbutil.o

没有错误或警告

最佳答案

添加 -Wl,--no-as-needed 作为链接器参数。

关于c - 自 ubuntu 升级以来对 `dlopen' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19926466/

相关文章:

c - 理解一行包含大括号和方括号的 C 代码

c - 为什么在执行不带 "%"的 printf 后打印字符 "\n"?

c - while 循环中的段错误 (C)

c - 索引与指针

c++ - 带有 X11/xlib 的 Ubuntu 热键,X 错误 : BadAccess

ubuntu - 如何读取文件A中的每一行/字符串,并在文件B中找到包含字符串的行并在ubuntu中删除它

C语言编程错误: expected specifier-qualifier-list before '{ '

c++ - ubuntu 18.10 上的 std::filesystem 链接错误

python - 如何使用 python apt 模块删除 ppa?

c - 从以下代码中获取警告 "cast to pointer from integer of different size"