What is a file with extension .a?

被刻印的时光 ゝ 提交于 2019-12-28 04:54:08

问题


I downloaded this: https://github.com/mongodb/mongo-c-driver

And now I'm trying to use it inside my C program, but I don't know what to do with the generated .a files. What are they? I couldn't find any information, not even in the GCC manual.

And I built it like so:

  scons --c99

Also, can I use C99 libraries with my C89 program?


回答1:


.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.




回答2:


.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.



来源:https://stackoverflow.com/questions/5965171/what-is-a-file-with-extension-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!