" LIB"对图书馆preFIX [英] "lib" Prefix on Libraries
问题描述
从<一个href=\"http://www.adp-gmbh.ch/cpp/gcc/create_lib.html\">http://www.adp-gmbh.ch/cpp/gcc/create_lib.html:
注:库必须先从三个字母
LIB
和具有后缀.A
块引用>这是一个操作系统约定,或
GCC
/AR
怪癖? X $ C $ç似乎能没有preFIX创建库。它是什么做不同?解决方案您可以命名任何你想要的库,但如果你想gcc的
-l </ code>标记找到合适的人,你需要它命名该链接描述的方式。例如:
的gcc -o的myapp myapp.c -lm
将编译
myapp.c
与libm.a
链接生成的对象,并要求输出的可执行文件的myapp </ code>。这些天来,有可能是涉及到动态库名称等更复杂的搜索路径,但你应该从这个例子中的基本理念。
从 gcc的手册页:
-l </ code>
库 ...
...包围的库的是
LIB
和.A
并搜索几个目录。
块引用>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
.Is this an operating system convention, or a
gcc
/ar
quirk? Xcode seems to be able to create libraries without the prefix. What's it doing differently?解决方案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 withlibm.a
, and output an executable calledmyapp
. 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.
这篇关于&QUOT; LIB&QUOT;对图书馆preFIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!