没有规则可以创建目标... libm.a

发布于 2024-08-10 09:19:54 字数 166 浏览 3 评论 0原文

当我尝试编译我的应用程序时,出现以下错误:

*** No rule to make target `/mypath/lib/libm.a', needed by `/myPath/bin/appName'

为什么链接器根据绝对路径查找 libm.a?

I get the following error when I try to compile my app:

*** No rule to make target `/mypath/lib/libm.a', needed by `/myPath/bin/appName'

Why is the linker looking for libm.a according to an absolute path?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小苏打饼 2024-08-17 09:19:54

我开始考虑将编程转为通灵职业......

为什么链接器要根据绝对路径寻找libm.a?

因为你告诉他这样做。您很可能已经输入了

# There were some rules that build your own .a libs
myLib.a: ...
   ...

# Handy rule to direct your libs into lib/ folder!
vpath %.a /mypath/lib

appName: appName.o libm.a
   g++ $^ -o $@

哎呀!您需要“system”libm.a(这是一个数学库,glibc 的一部分),但 make 认为您需要自己的静态库。然后它添加了正确的前缀,但没有找到任何规则来重新创建libm.a

解决方案可能是将 libm.a 移出先决条件。这就是配置脚本或特殊 make sanity 目标检查系统库是否存在的目的。

EXT_LIBS=libm.a

appName: appName.o
   g++ $^ $(EXT_LIBS) -o $@

I start thinking of swithcing programming to psychic career...

Why is the linker looking for libm.a according to an absolute path?

Because you told him to do so. Most likely you've typed

# There were some rules that build your own .a libs
myLib.a: ...
   ...

# Handy rule to direct your libs into lib/ folder!
vpath %.a /mypath/lib

appName: appName.o libm.a
   g++ $^ -o $@

Whoops! You need "system" libm.a (that's a math library, a part of glibc), but make thinks that you need your own static library. It then adds the proper prefix and doesn't find any rule to remake libm.a.

A solution could be moving libm.a out of prerequisites. That's the purpose of configure script or a special make sanity target to check the existence of system libraries.

EXT_LIBS=libm.a

appName: appName.o
   g++ $^ $(EXT_LIBS) -o $@
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文