0

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.

Community
  • 1
  • 1
Hell0
  • 349
  • 1
  • 6
  • 19
  • 3
    Fedora does have libm.a. As the link you list points out, libm.a is available from the glibc-static package. – Ciclamino Dec 06 '16 at 19:02
  • Thanks, but why? if i understood correctly _libm.a_ is a standard library for maths. I'm not searching for a void() discussion. I think that if it is not included on the whole _distro_ it must be a reason. Do you know it? – Hell0 Dec 06 '16 at 19:11
  • 4
    libm.a is the static version of the math library and it is, obviously, included in the whole distro since it's in glibc-static. Most people don't need static libraries so they are in a different package. Note that the shared math library (libm.so) is found in glibc-devel. – Ciclamino Dec 06 '16 at 19:34
  • 1
    Are you aware that unless you use `gcc -c`, the compiler expects a `main()` function? That's exactly what the error message said! – Jens Dec 06 '16 at 20:59
  • I had saw the output, onestly i'm not undertanding the compiler message, but in `man`: `When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.' – Hell0 Dec 06 '16 at 21:09
  • Is not my language and i must read very well before say anything! – Hell0 Dec 06 '16 at 21:10
  • ... but yes, i tested that you said, `gcc` had do a `bin` file, but is not possible to execute before check file permissions. It is very weird all of that!! – Hell0 Dec 06 '16 at 21:12

1 Answers1

3

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

mattdm
  • 2,082
  • 25
  • 39