什么是扩展名为.a 的文件?

我下载了这个: https://github.com/mongodb/mongo-c-driver

现在我尝试在我的 C 程序中使用它,但是我不知道如何处理生成的代码。一份文件。他们是什么?我找不到任何信息,甚至在海湾合作委员会的手册里也找不到。

我是这样建造的:

  scons --c99

另外,我可以在 C89程序中使用 C99库吗?

141093 次浏览

.a files are static libraries typically generated by the archive tool. You usually include the header files associated with that static library and then link to the library when you are compiling.

.a files are created with the ar utility, and they are libraries. To use it with gcc, collect all .a files in a lib/ folder and then link with -L lib/ and -l<name of specific library>.

Collection of all .a files into lib/ is optional. Doing so makes for better looking directories with nice separation of code and libraries, IMHO.