c - Lua C API : undefined reference errors in liblua.a

标签 c linker lua

我正在尝试编译一个包含 Lua(5.2) 库的简单 C 代码示例。我正在使用以下命令:

gcc graph.c -o graph -I/usr/local/include -L/usr/local/lib -llua

并出现以下错误:

    /usr/local/lib/liblua.a(lobject.o): In function `luaO_arith':
    lobject.c:(.text+0x15c): undefined reference to `floor'
    lobject.c:(.text+0x111): undefined reference to `pow'
    /usr/local/lib/liblua.a(lvm.o): In function `luaV_execute':
    lvm.c:(.text+0x24e9): undefined reference to `floor'
    lvm.c:(.text+0x25fe): undefined reference to `pow'
   ...

看起来数学库没有链接,但不确定如何修复它......有什么建议吗?我按照自述文件中的说明使用 make linux 和 install linux (有 Ubuntu 12.04)安装了 Lua。谢谢!

最佳答案

非常简单:您只需将 -lm 添加到行尾即可。

(所有需要它的函数的手册页都会提到这一点。)

关于c - Lua C API : undefined reference errors in liblua.a,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15592360/

相关文章:

c++ - 如何使用makefile生成自动头文件

c++ - 未定义对弱函数的引用(静态库+ GCC)

nginx - 使用 Openresty 向 Google Analytics 发送 http 请求

c - 对 ld : warning: section `.bss' type changed to PROGBITS 的负面影响

C++ 链接器失败,因为我添加了一个 throw

c++ - 以编程方式嵌入 Lua 加载模块 (C++)

class - 'o = o or {}'在Lua中做什么?

c - 从文件中读取数字并计算总和和平均值

c - 在 Linux 上使用 TCP 进行文件传输

java - 高容量 SVM(机器学习)系统