work hard work smart

专注于Java后端开发。 不断总结,举一反三。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

搭建程序框架

Posted on 2022-04-05 21:01  work hard work smart  阅读(65)  评论(0编辑  收藏  举报

在/home/study/weatherdata/project/idc2下创建如下文件夹

 

 在c文件夹下,创建crtsurfdata1.cpp

#include "_public.h"

CLogFile logfile(10);

int main(int argc, char *argv[]){

        // printf("argc %s  \n",argc);
        // inifile outpath logfile
        if( argc != 4){
                printf("Using: ./crtsurfdata1 inifile outpath logfile\n");
                return  -1;
        }

        if(logfile.Open(argv[3]) == false){
                printf("logfile.Open(%s) failed.\n", argv[3]);
                return -1;
        }

        logfile.Write("crtsurfdata1 开始运行。\n ");

        for(int ii = 0;ii<10000000;ii++)
                logfile.Write("这是第%010d条日志记录。\n",ii);

        logfile.Write("crtsurfdata1 结束运行。\n ");

        return 0;
}

  

在c文件夹下创建makefile

PUBINCL = -I/home/study/weatherdata/project/public

PUBCPP = /home/study/weatherdata/project/public/_public.cpp

CFLAGS = -g

all:crtsurfdata1

crtsurfdata1:crtsurfdata1.cpp
        g++  $(CFLAGS)  -o  crtsurfdata1  crtsurfdata1.cpp $(PUBINCL) $(PUBCPP)  -lm -lc
        cp crtsurfdata1  ../bin/.
clean:
        rm crtsurfdata1

  

使用make命令

 

 

执行

/home/study/weatherdata/project/idc2/bin/crtsurfdata1  /home/study/weatherdata/project/idc2/ini/stcode.ini  /tmp/surfdata   /home/study/weatherdata/project/idc2/crtsurfdata1.log