How does a C compiler find that -lm is pointing to the file libm.a?

前端 未结 3 558
误落风尘
误落风尘 2021-02-09 15:22

What\'s .a files in C programming in linux ? Is it library file ?

To merge with the math library libm.a you would type

 cc -o program_name prog.c -lm

when you         


        
3条回答
  •  忘掉有多难
    2021-02-09 16:21

    The compiler "knows" to look for libm.a (or libm.so) when you pass it the option -lm, because that's how the -l option is documented and implemented: Take the characters following -l (here just m), prefix lib and suffix .a to get libm.a

    Each library can have its own relation between header and library files used. It's uncommon for a header file to require no library at all, but it's more common for a library to have multiple header files.

提交回复
热议问题