Fedora动态替代libm.a(静态lib)吗? [英] Fedora dynamic replacement for libm.a(static lib)?

查看:149
本文介绍了Fedora动态替代libm.a(静态lib)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想弄清楚,为什么 Fedora 没有静态库libm.a,如果事实是我应该使用的 ? 如 StackOverflow 中此处所述. strong>我可以简单地从yum安装 pkg ,但是可以认为 Fedora 可以替代默认的 lib . ?

I'm just trying to figure it out, why Fedora has not the static library libm.a, and if it is a fact, which i should use? As mentioned here in StackOverflow i can simply install the pkg from yum, but is acceptable to think that Fedora have a replacement as default lib instead.No?

已编辑

我正在尝试编译它:

#include <stdio.h>
#include <stdlib.h>

void fred(int arg)
{
    printf("fred: you passed %d\n", arg);
}

输出是这样的:

$ gcc -o fred fred.c /usr/lib64/libm.so
/usr/lib/gcc/x86_64-redhat-linux/6.2.1/../../../../lib64/crt1.o: En la función `_start':
(.text+0x20): referencia a `main' sin definir
collect2: error: ld devolvió el estado de salida 1

使用lm/usr/lib/libm.a/usr/lib64/libm.a

我已经完成了所有在这里和其他帖子中提及的内容,yum install glibc-static,并检查了/usr/lib64/libm.so

I've done all mencioned here and other posts, yum install glibc-static and checked for /usr/lib64/libm.so

编辑

repoquery --whatprovides /usr/lib64/libm.a:

failure: repodata/repomd.xml from fedora-cisco-openh264: [Errno 256] No more mirrors to try.
https://codecs.fedoraproject.org/openh264/24/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for fedora-cisco-openh264

谢谢.

推荐答案

这里有几件事....

  1. 在您的小示例中,您无需使用任何数学函数,因此您实际上并不需要libm

  1. You don't use any math functions in your little example, so you don't really need libm

如果您 did 需要libm,则实际上并不需要 static libm.a.您可以链接到动态链接,可以使用gcc -lm进行链接,而不是直接指定文件名.

If you did need libm, you don't really need the static libm.a. You can link against the dynamic one, and you can do this with gcc -lm rather than giving the file name directly.

如果出于某些原因 did 需要libm.a,则可以在glibc-static软件包中找到它-但出于很多原因,不建议这样做.

If you did need libm.a for some reason, you could find it in the glibc-static package — but for a whole host of reasons this is not recommended.

如错误消息所述,真正的错误是您缺少main()函数.尝试将其添加到文件底部:

As the error message says, what's really wrong is that you're missing a main() function. Try adding this to the bottom of your file:

int main(int argc,char ** argv) { fred(1); fred(2); fred(42); }

int main (int argc, char **argv) { fred(1); fred(2); fred(42); }

然后使用gcc -o fred fred.c

这篇关于Fedora动态替代libm.a(静态lib)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆