“lib” Prefix on Libraries

前端 未结 1 1561
余生分开走
余生分开走 2020-12-10 03:56

From http://www.adp-gmbh.ch/cpp/gcc/create_lib.html:

Note: the library must start with the three letters lib and have the suffix .a

相关标签:
1条回答
  • 2020-12-10 04:10

    You can name a library whatever you want, but if you want gcc's -l flag to find the right one, you need to name it the way that link describes. For example:

    gcc -o myapp myapp.c -lm
    

    Will compile myapp.c, link the resulting object with libm.a, and output an executable called myapp. These days, there might be a more complicated search path involving dynamic library names, etc., but you should get the basic idea from this example.

    From the gcc man page:

    -l library ...

    ... surrounds library with lib and .a and searches several directories.

    0 讨论(0)
提交回复
热议问题