女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

Cmake學習的總結(三)

電子設計 ? 來源:電子設計 ? 作者:電子設計 ? 2020-12-24 17:45 ? 次閱讀

大家好,在上一篇文Cmake文章里面,我們同樣在文章的最后面留了一個問題實現,就是把源文件放到src目錄下,把頭文件放到include目錄下去,這樣也比較符合別人和自己日后去配置工程(一看到這兩個目就能知道啥意思了,清晰明了),同時在linux環境下生成的elf文件放到bin目錄下;不過在文章發出去了幾天,后面有網友又有提出了一些新的需求:

(如果網友有啥實際需要,可以私聊我,只要在我自身能力之內,我都可以寫成文章出來分享給大家)熟悉我的網友都知道,我也是小白,會從很基礎的東西開始分享開始,雖然都是比較理論化的東西,但是都是點滴的積累(有的時候,其實你真正在有些項目開發過程中,學到的東西不是很多,更多的是依靠平時的基礎積累加以擴展,所以總的來說,平時的折騰還是非常值得!);同時有啥比較實際一點的需求咋也慢慢深入,一步步來,穩扎穩打,知識性的東西來不得半點虛假和馬虎。好了,開始進入主題分享了:

一、src、include、bin目錄的使用(更加正規化):

1、先開始創建這三個目錄結構,并把相應的文件放入進去:

root@txp-virtual-machine:/home/txp/testmy# mkdir bin build src include

root@txp-virtual-machine:/home/txp/testmy# ls

bin build include src

include目錄下文件放入(這里test1.h和test2.h的內容是接續前面的文章里面的內容,這里我就不再造輪子了):

root@txp-virtual-machine:/home/txp/testmy/include# ls

test1.h test2.h

src目錄下文件放入(這里test1.c和test2.c的內容是接續前面的文章里面的內容,這里我就不再造輪子了):

root@txp-virtual-machine:/home/txp/testmy/src# ls

main.c test1.c test2.c

最終我們還要在testmy目錄和src目錄下都創建一個CMakeLists.txt:

/*testmy目錄下的CMakeLists.txt內容:*/

cmake_minimum_required(VERSION 2.8)

project(main)

add_subdirectory(src)

/*src目下CMakeLists.txt內容:*/

aux_source_directory(. SRC_LIST)

include_directories(../include)

add_executable(main ${SRC_LIST})

set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

上面第一個CMakeLists.txt里面陌生的語句解釋:

add_subdirectory(src)意思是可以向當前工程添加存放源文件的子目錄,并可以指定中間二進制和目標二進制的存放位置(subdirectory字母就是子目錄的意思,所以意思是:這里指定src目錄下存放了源文件,當執行cmake時,就會進入src目錄下去找src目錄下的CMakeLists.txt,所以在src目錄下也建立一個CMakeLists.txt),官方用法是這樣的(不過這里暫時沒去深究):

add_subdirectory

----------------

Add a subdirectory to the build.

::

add_subdirectory(source_dir [binary_dir]

[EXCLUDE_FROM_ALL])

Add a subdirectory to the build. The source_dir specifies the

directory in which the source CMakeLists.txt and code files are

located. If it is a relative path it will be evaluated with respect

to the current directory (the typical usage), but it may also be an

absolute path. The binary_dir specifies the directory in which to

place the output files. If it is a relative path it will be evaluated

with respect to the current output directory, but it may also be an

absolute path. If binary_dir is not specified, the value of

source_dir, before expanding any relative path, will be used (the

typical usage). The CMakeLists.txt file in the specified source

directory will be processed immediately by CMake before processing in

the current input file continues beyond this command.

If the EXCLUDE_FROM_ALL argument is provided then targets in the

subdirectory will not be included in the ALL target of the parent

directory by default, and will be excluded from IDE project files.

Users must explicitly build targets in the subdirectory. This is

meant for use when the subdirectory contains a separate part of the

project that is useful but not necessary, such as a set of examples.

Typically the subdirectory should contain its own project() command

invocation so that a full build system will be generated in the

subdirectory (such as a VS IDE solution file). Note that inter-target

dependencies supercede this exclusion. If a target built by the

parent project depends on a target in the subdirectory, the dependee

target will be included in the parent project build system to satisfy

the dependency.

第二個CMakeLists.txt內容分析:

aux_source_directory (. SRC_LIST):把當前目錄的源文件:main.c test1.c test2.c都放到變量SRC_LIST里面去。

include_directories (../include):把include目錄的頭文件包含進來。

set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin):這里面的EXECUTABLE_OUT_PATH和PROJECT_SOURCE_DIR是CMake自帶的預定義變量,同時他們的作用分別如下:

EXECUTABLE_OUTPUT_PATH :目標二進制可執行文件的存放位置

PROJECT_SOURCE_DIR:工程的根目錄

所以最終生成的elf文件(也就是我們的最終可執行文件)就會放到bin目錄下,然后我們build目錄下會成一些配置中間文件。

具體步驟過程我寫出來:

root@txp-virtual-machine:/home/txp/testmy# vim CMakeLists.txt

root@txp-virtual-machine:/home/txp/testmy# cd src

root@txp-virtual-machine:/home/txp/testmy/src# ls

main.c test1.c test2.c

root@txp-virtual-machine:/home/txp/testmy/src# vim CMakeLists.txt

審核編輯:符乾江
聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 二進制
    +關注

    關注

    2

    文章

    803

    瀏覽量

    42131
  • 嵌入式設計
    +關注

    關注

    0

    文章

    393

    瀏覽量

    21649
收藏 人收藏

    評論

    相關推薦
    熱點推薦

    使用STM32CubeMX生成CMake工程中的FLASH.ld被更改怎么解決?

    使用STM32CubeMX生成CMake工程之后,對STM32xxxx_FLASH.ld進行了修改。然后再次使用STM32CubeMX對工程進行修改的時候,STM32xxxx_FLASH.ld文件匯總被修改的部分會被恢復原狀。請問各位有沒有好的辦法能夠解決這個問題,煩請指教!!!
    發表于 03-10 06:52

    在CubeMX V6.13.0版本上配置的CMake工程無法通過編譯怎么解決?

    在 CubeMX V6.13.0 版本上配置的 CMake 工程無法通過編譯,報錯如下圖
    發表于 03-07 16:59

    為什么無法在OpenVINO? 2021.3源中使用CMAKE編譯ONNX模型?

    嘗試從源版本 2021.3 編譯OpenVINO? 錯誤: ~/項目/OpenVINO/cmake-build-debug/_deps/ext_onnx-src/onnx/onnx_pb.h
    發表于 03-05 08:29

    TOF學習總結

    iToF(間接飛行時間)技術中,波長越短,分辨細節的能力越好,主要原因與光的波動特性和調制信號的特性密切相關。以下是詳細解釋:1. 光的波動特性:波長與分辨率的關系波長越短,空間分辨率越高:光的波長決定了其能夠分辨的最小細節。根據光學理論,分辨率與波長成反比,波長越短,能夠分辨的特征尺寸越小。例如,可見光的波長(400-700 nm)比紅外光(通常用于iToF,波長約850 nm)更短,因此可見光能夠分辨更細微的細節。衍射極限:光的衍
    發表于 02-25 17:49 ?0次下載

    關于中斷知識學習總結筆記

    《關于中斷知識學習總結筆記》 一、中斷的核心概念 中斷是計算機運行過程中的一種重要機制,它能夠使計算機在執行主程序時,暫停當前任務去響應特定的事件或請求,處理完成后再返回主程序繼續執行。這就像是一個
    發表于 11-23 11:23

    AM17x功耗總結

    電子發燒友網站提供《AM17x功耗總結.pdf》資料免費下載
    發表于 10-12 09:14 ?0次下載
    AM17x功耗<b class='flag-5'>總結</b>

    人工智能、機器學習和深度學習是什么

    在科技日新月異的今天,人工智能(Artificial Intelligence, AI)、機器學習(Machine Learning, ML)和深度學習(Deep Learning, DL)已成為
    的頭像 發表于 07-03 18:22 ?2519次閱讀

    執行build.py menuconfig時報“ Unknown CMake command \"__add_uf2_targets\".”錯誤,請問是什么原因?

    執行build.py menuconfig時報“Unknown CMake command \"__add_uf2_targets\".”錯誤,請問這是什么原因?
    發表于 06-27 06:21

    大模型技術及趨勢總結

    本篇文章旨在希望大家對大模型的本質、技術和發展趨勢有簡單的了解。由于近期大模型技術發展很快,這里對大模型的技術、本質及未來趨勢進行總結和探討時,因為水平有限,疏漏在所難免。請大家諒解。 引言 大模型
    的頭像 發表于 06-21 17:38 ?924次閱讀
    大模型技術及趨勢<b class='flag-5'>總結</b>

    idf.py menuconfig的時候總是提示cmake301 error的原因?

    idf.py menuconfig的時候總是,提示cmake301 error 提示沒有這個目錄,手動創建目錄之后,還會出現更多依賴目錄 例: CMake Error at /home
    發表于 06-20 06:01

    剛剛裝好esp32 elipse CMAKE編譯環境,hello word編譯不通過怎么解決?

    CMake Error at E:/Work/eclipse-esp/esp-idf/tools/cmake/component.cmake:305 (message): Include
    發表于 06-18 06:15

    華為PCBA檢查規范設計總結

    福利來啦! 給大家分享《華為PCBA檢查規范設計總結
    的頭像 發表于 06-15 16:25 ?2463次閱讀
    華為PCBA檢查規范設計<b class='flag-5'>總結</b>

    嵌入式學習-飛凌ElfBoard ELF 1板卡 - 如何在Ubuntu中編譯OpenCV庫

    elf@ubuntu:~/work/opencv/opencv-3.4.1$ mkdir install build:是構建目錄。 install:是安裝目錄。 (5)安裝cmakecmake-gui工具和依賴
    發表于 06-07 09:21

    Espressif-IDE編譯報錯的原因?

    大家好。我頭一回使用Espressif-IDE,開始學習。我新建了工程,使用hello_world模版,編譯時報錯,是關于python的。錯誤如下: C
    發表于 06-07 07:34

    VSCode中編譯過程cmake錯誤的原因?

    VSCode中編譯產生一個問題,問題如下: CMake Error at CMakeLists.txt:1 (idf_component_register):Unknown CMake command
    發表于 06-06 06:48