如何在Makefile中找到适当的LDFLAG?

时间:2012-04-09 03:53:02

标签: c++ ios linker makefile clang

在Makefile中将LDFLAGS与LDFLAGS链接时,如何知道库的名称?

例如:

libxml2.dylib与-lxml2

链接

实际命名为zlib的libz.dylib与-lz

链接

指定的那些标志在哪里?如何看待它们?

1 个答案:

答案 0 :(得分:2)

按照惯例,您从库文件名中删除前面的“lib”。对于名为“libmyspecial_library.so”的库文件,相应的标志为:

-lmyspecial_library

这实际上是gcc编译器的约定。有关详细信息,请参阅gcc man page

   -llibrary
      Use the library named library when linking.

      The  linker searches a standard list of directories
      for the library, which is  actually  a  file  named
      `liblibrary.a'.   The linker then uses this file as
      if it had been specified precisely by name....