我正在尝试编译一个依赖于依赖于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,这些未定义的引用都不会消失。 / p>
我正在尝试在ubuntu 12.04 LTS上编译这个lib
请帮助
答案 0 :(得分:1)
问题是我使用的共享库是使用不同版本的GCC构建的。在我从Ubuntu 11.04(从12.04 LTS)降级后,它已经解决了。