我使用binfmtc允许我在不执行显式构建步骤的情况下运行C程序。这工作正常,直到我开始使用数学函数,此时我看到如下消息:
对'sin'
的未定义引用
我使用的标题是:
/*BINFMTC: -Wall -Werror -std=c99 -lm
*/
如何才能将此程序链接起来?
密切相关:"undefined reference to `pow'" even with math.h and the library link -lm
答案 0 :(得分:1)
这不优雅,但有效:
为库创建包装器脚本gcclm.sh
:
#! /usr/bin/env bash
gcc $@ -lm
使用包装器调用C程序:
GCC=$(pwd)/gcclm.sh ./myprogram.c