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

前端 未结 3 549
误落风尘
误落风尘 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:24

    .a files are static libraries, as opposed to .so files which are dynamic libraries. Normally gcc looks for dynamic libraries if available unless passed -static.

    The header contains definitions that the compiler needs in order to build the source code into an object file, but the libraries contain the actual routines that the linker needs to turn the object file into an executable.

提交回复
热议问题