国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

cmake 學(xué)習(xí)筆記

2019-11-11 04:54:52
字體:
供稿:網(wǎng)友

cmake 學(xué)習(xí)筆記

測試環(huán)境,Ubuntu 14.04

參考:http://blog.csdn.net/dbzhang800/article/details/6314073


例子1:helloworld

目錄結(jié)構(gòu)如下

.├── build├── CMakeLists.txt└── main.c1 directory, 2 files

其中CMakeLists.txt

PRoject(HELLO)set(SRC_LIST main.c)add_executable(hello ${SRC_LIST})message(${PROJECT_SOURCE_DIR})message(${PROJECT_SOURCE_DIR})message(${PROJECT_SOURCE_DIR})

main.c

#include<stdio.h>int main(){ printf("helloworld/n"); return 0;}

先創(chuàng)建CMakeLists.txtmain.c這兩個文件,然后新建build目錄,cd到build目錄下,執(zhí)行(cmake 命令后跟一個路徑(..),用來指出 CMakeList.txt 所在的位置。)

cmake ..make

這里寫圖片描述

生成的hello即為可執(zhí)行程序。


例子2: helloworld again !

在main.c 同目錄下增加兩個文件hello.hhello.c

#ifndef _HELLO__#define _HELLO__void hello(const char* name);#endif //_HELLO__#include <stdio.h>#include "hello.h"void hello(const char* name){ printf("hello %s again!/n", name);}#include "hello.h"int main(){ hello("world"); return 0;}

CMakeLists.txt

project(HELLO)set(SRC_LIST main.c hello.c)add_executable(hello ${SRC_LIST})

執(zhí)行cmake的過程同上


例子3:

生成一個庫。

修改CMakeLists.txt

project(HELLO)set(LIB_SRC hello.c)set(APP_SRC main.c)add_library(libhello ${LIB_SRC})add_executable(hello ${APP_SRC})target_link_libraries(hello libhello)
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 栾城县| 汽车| 若尔盖县| 射阳县| 东源县| 屯昌县| 武平县| 宁强县| 云安县| 莆田市| 永清县| 磴口县| 甘肃省| 临高县| 祁连县| 登封市| 温宿县| 虞城县| 临漳县| 临海市| 牟定县| 栾城县| 尼木县| 甘肃省| 绿春县| 浪卡子县| 城口县| 通山县| 永新县| 阿城市| 七台河市| 南漳县| 双牌县| 宝应县| 天水市| 桃江县| 宜阳县| 三门县| 车险| 皋兰县| 开江县|