windows环境下使用cmake构建一个工程

简单记录一下在windows环境下使用cmake构建工程

任务

  • cmake一个工程
  • 静态库和动态库的构建与安装
  • 外部共享库和头文件的使用

前期准备

先找一个路径 [D:\DamonWS\STUDY\4-5-6-Linux\CMAKE] 建立如下code1 code2 code3 三个文件夹

D:\DamonWS\STUDY\4-5-6-Linux\CMAKE> tree
.
├── code1
├── code2
└── code3

CMake一个工程

代码工程在目录下的code1文件夹

1、步骤一,写好C代码

先在code1下创建一个src文件夹,随后创建fun.c fun.h main.c文件

fun.c 中的内容

#include "stdio.h"

int add(int a,int b)
{
   
   
    int c = a+b;
    return (c);
}

fun.h 中的内容

#ifndef _FUN_H_
#define _FUN_H_

int add(int a,int b);

#endif

main.c 中的内容

#include "stdio.h"
#include <stdlib.h>
#include "fun.h"

int main(int argc, char* argv[])
{
   
   
    printf("main >> hello world !\n");
    if(argc < 3)
    {
   
   
        printf("Usage: %s input error\n", argv[0]);
        return -1;
    }
    int a = atoi(argv[1]); //取传入参数1
    int b = atoi(argv[
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值