"未定义参考"即使是lib也有功能的象征

时间:2014-08-28 07:31:01

标签: c apr

当我链接.o文件时,发生了一些问题:

gcc -L/usr/local/apr/lib -lapr-1 -pthread -laprutil-1  devpkg.o bstrlib.o db.o shell.o commands.o   -o devpkg
devpkg.o: In function `main':
/root/workspace/devpkg/devpkg.c:21: undefined reference to `apr_pool_initialize'
/root/workspace/devpkg/devpkg.c:22: undefined reference to `apr_pool_create_ex'
/root/workspace/devpkg/devpkg.c:36: undefined reference to `apr_getopt_init'
/root/workspace/devpkg/devpkg.c:38: undefined reference to `apr_getopt'

我使用“objdump -T”来检查lib,它返回了:

objdump -T libapr-1.so|grep apr_pool_initialize
000000000001db00 g    DF .text  00000000000000fb  Base        apr_pool_initialize

为什么会这样?

1 个答案:

答案 0 :(得分:1)

这很可能只是一个简单的依赖问题。您可能希望在.o文件之后按照正确的顺序列出所有链接到的库。根据它们之间的依赖关系。