如何链接在C静态库? [英] How to link to a static library in C?

查看:170
本文介绍了如何链接在C静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用code ::块编译我的静态库。输出结果是一个libstatic.a文件。
现在,我如何链接到我的图书馆使用被编译的功能呢?

(我试图使用的#includelibstatic.a,但我的项目不编译)


解决方案

  CC -o yourprog yourprog.c -lstatic

  CC -o yourprog yourprog.c libstatic.a

I use code::blocks to compile my static library. The output result is a libstatic.a file. Now, how do I link to my library to use functions that were compiled?

(I tried to use #include "libstatic.a" but my project doesn't compile)

解决方案

cc -o yourprog yourprog.c -lstatic

or

cc -o yourprog yourprog.c libstatic.a

这篇关于如何链接在C静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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