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

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

问题描述

我使用 code::blocks 来编译我的静态库.输出结果是一个 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?

(我尝试使用 #include "libstatic.a" 但我的项目无法编译)

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

推荐答案

cc -o yourprog yourprog.c -lstatic

cc -o yourprog yourprog.c libstatic.a

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

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