1.使用vs2013创建普通的应用台控制程序

2.在属性里选择静态库(.lib)

如何编写静态库

编写库文件:

// mylib.h
#pragam once
int sum(int a,int b); 
//mylib.c
#include "mylib.h"
//函数实现
int sum(int a,int b)
{
   return (a+b);
}

3.编译,成功后会在目录下生成.lib文件

4.使用示例:

#include "mylib.h" // 使用库中的头文件
#include <stdio.h>
#pragam comment(lib,"mylib.lib") // 链接库文件
int main()
{
   int a = 1,b =2;
   printf("sum = %d \n",sum(a,b));
   return 0;
}

 或者不想每次都要链接库文件,就把环境配置好:

   01.打开属性

如何编写静态库

  02.添加头文件目录、库文件目录等:

如何编写静态库

如何编写静态库

  Done!然后就不用这句了:

#pragam comment(lib,"mylib.lib"); // 手动链接库

  

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2021-04-01
  • 2022-01-06
  • 2021-06-06
  • 2021-05-21
  • 2022-12-23
猜你喜欢
  • 2021-05-06
  • 2022-01-20
  • 2021-09-18
  • 2021-09-08
  • 2022-01-12
  • 2022-12-23
相关资源
相似解决方案