【发布时间】:2010-11-16 02:31:43
【问题描述】:
在 Linux 上编译使用 POSIX aio 库(例如 aio_read()、aio_write() 等)的示例程序时,我遇到了链接器问题。
我正在运行带有 2.6 内核的 Ubuntu,并已使用 apt-get 实用程序安装 libaio。但即使我正在链接 aio 库,编译器仍然给我链接器错误。
root@ubuntu:/home# g++ -L /usr/lib/libaio.a aio.cc -oaio
/tmp/cc5OE58r.o: In function `main':
aio.cc:(.text+0x156): undefined reference to `aio_read'
aio.cc:(.text+0x17b): undefined reference to `aio_error'
aio.cc:(.text+0x191): undefined reference to `aio_return'
collect2: ld returned 1 exit status
如果不在库 libaio.a 中,所有这些 aio_x 函数实际定义在哪里?
【问题讨论】:
-
是的。我也试过 g++ -L /usr/lib64/libaio.a aio.cc -oaio 但得到了同样的链接器错误
-
您没有链接到 aio 库,您只是将“/usr/lib/libaio.a”添加到库路径中。