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

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

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

2019-11-11 03:44:44
字體:
供稿:網(wǎng)友

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

測(cè)試環(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這兩個(gè)文件,然后新建build目錄,cd到build目錄下,執(zhí)行(cmake 命令后跟一個(gè)路徑(..),用來指出 CMakeList.txt 所在的位置。)

cmake ..make

這里寫圖片描述

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


例子2: helloworld again !

在main.c 同目錄下增加兩個(gè)文件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:

生成一個(gè)庫(kù)。

修改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ā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 深圳市| 韩城市| 黎平县| 台山市| 淅川县| 南平市| 福泉市| 尼木县| 克什克腾旗| 雷山县| 钟山县| 曲麻莱县| 霞浦县| 平阴县| 梧州市| 丰顺县| 中江县| 江川县| 阳东县| 嘉祥县| 乐都县| 永胜县| 盘山县| 瑞金市| 花垣县| 南安市| 永寿县| 铜鼓县| 化州市| 东方市| 丘北县| 喜德县| 白银市| 资阳市| 丹阳市| 尤溪县| 墨脱县| 新兴县| 鹿泉市| 鹤庆县| 隆林|