" LIB"对图书馆preFIX [英] "lib" Prefix on Libraries

查看:111
本文介绍了" LIB"对图书馆preFIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从<一个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 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.

这篇关于&QUOT; LIB&QUOT;对图书馆preFIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆