问题
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....
You don't use any math functions in your little example, so you don't really need libm
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 withgcc -lm
rather than giving the file name directly.If you did need
libm.a
for some reason, you could find it in theglibc-static
package — but for a whole host of reasons this is not recommended.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