Fedora dynamic replacement for libm.a(static lib)?

守給你的承諾、 提交于 2019-12-12 03:53:40

问题


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?


edited

I'm trying to compile this:

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

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

and the output is this:

$ 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

Test ggc with lm and /usr/lib/libm.a and /usr/lib64/libm.a

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


edit

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

thanks.


回答1:


Several things here....

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

  2. 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.

  3. 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.

  4. 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); }

and then compile with gcc -o fred fred.c



来源:https://stackoverflow.com/questions/41002773/fedora-dynamic-replacement-for-libm-astatic-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!