在Makefile中将LDFLAGS与LDFLAGS链接时,如何知道库的名称?
例如:
libxml2.dylib与-lxml2
链接实际命名为zlib的libz.dylib与-lz
链接指定的那些标志在哪里?如何看待它们?
答案 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....