1

我正在尝试编译一个依赖于 liblua51.so 的共享库(so)的简单示例程序。我的源文件是 example.c,这是我用来编译它的命令(它是用 C 编写的)

cc -Wall -fPIC -ldl -o a.out -I./ste-linux/ste-interface-files/c/ -L./ste-linux/ste-shared-libraries/ example.c -lm -llua51 -lste -lm -ldl

我收到以下错误:

./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sinh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `ceil'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `atan2'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `tanh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `cosh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `fmod'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `acos'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sin'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `atan'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `asin'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `exp'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `tan'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `cos'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `log'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `pow'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `log10'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sqrt'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `floor'

我在 stackoverflow 上阅读了一堆其他线程,说添加 -lm 标志可以解决这个问题,但是无论我将 -L 和 -lm -ldl 放在命令中的哪个位置,这些未定义的引用都不会消失。

我正在尝试在 ubuntu 12.04 LTS 上编译这个库

请帮忙

4

1 回答 1

1

问题是我使用的共享库是用不同版本的 GCC 构建的。在我从 Ubuntu 11.04(从 12.04 LTS)降级后,它得到了解决。

于 2013-06-24T03:20:25.677 回答