前言當我們有時候想要在 C++ 使用第三方套件的時候,我們需要下 -I (大寫的 i),
來幫助我們使用套件,
因為我是從 Python 學習過來的,
所以一開始的時候,對這一點非常的不習慣,
在 Python 的習慣的流程是先作類似 pip install 後,直接 import package 即可。(這邊講的是通常,並非全部)
而 C++ 在這部份並不相同。
這裡我們以我經常使用的 C++ OpenCV 與 C++ Tensorflow 為例子
C++ OpenCV mac 安裝 OpenCVmac 安裝 OpenCV,需要在終端機輸入以下指令 brew install opencv
C++ Tensorflow step 1. git clone – 把 tensorflow 的 Library 下載下來git clone https://github.com/tensorflow/tensorflow
step 2. 連同剛剛 git clone 的 repo,建立資料夾結構如下因為檔案非常的多,這邊只舉部分的檔案作為例子
tensorflow test_tensor_flow.cpp (我們測試用的檔案) step 3. 寫一些測試用的程式,以下舉個範例#include <iostream>
#include "tensorflow/lite/core/c/common.h"
int main() {
TfLiteTensor* tensor = nullptr;
return 0;
}
step 4. compile cpp 檔案,使用 Tensorflow library,下 -I tensorflow (大寫的 i)g++ test_simple_tensor.cpp -I tensorflow # uppercase i
其他的一些延伸問題'tensorflow/lite/c/common.h' file not found
需要使用 -I 的方式,IWYU 代表的是 include what you use 的縮寫,
總之 include 方式錯誤,需要研究 -I 的方式怎麼用 #include "tensorflow/lite/core/c/c_api_types.h" // IWYU pragma: export
Reference⭐C++ 基礎用法 相關文章整理⭐: 1. 【C++】C++ compile 程式碼 使用 c++ 11 與使用相關的 package 2. 【C++】C/C++ 顯示資料的類別 (type) sample code (內含範例程式碼) print C data type, cout C++ data type, get variable type in c++ 3. 【C++】C++ 複製 2D array的方法 copy 2d array memcpy sample code (內含範例程式碼) ⭐Modern C++ ⭐: ⭐C++ 字串處理相關文章整理⭐: 1. 【C++】字串 char string stringstream 相關用法總整理 (內含範例程式碼) 與利用 sprinf, snprinf assign 值的方法 2. 【C++】字串 char string stringstream 「轉換」用法總整理 (內含範例程式碼) 3. 【C】printf, fprintf, sprintf, snprintf 相關用法總整理 (內含範例程式碼) 4. 【C++】C++ String 用法 連接兩個 String c++ string concat ⭐C++ 系統偵測相關文章整理⭐: 1. 【C++】C++ 利用 dirent.h 計算資料夾的檔案數量 count files sample code (內含範例程式碼) 2. 【C++】C++ inotify sample code 偵測指定路徑底下的文件變化 (內有範例程式碼) ⭐C++ OpenCV 相關文章整理⭐: 1. 【OpenCV】c++ OpenCV – 在 ubuntu 上第一次執行 OpenCV 程式 sample code (內含範例程式碼) 2. 【OpenCV】c++ OpenCV - 在圖片上寫上文字 cv::putText sample code (內含範例程式碼) 3. 【OpenCV】c++ OpenCV - cv::Rect 矩形用法與相關功能函數 sample code (內含範例程式碼) 4. 【OpenCV】c++ OpenCV - OpenCV 中的純量 定義顏色 cv::Scalar(255,255,255) color sample code (內含範例程式碼) 5. 【OpenCV】用 C++ 計算 iou 的方法 與網路算法常見錯誤(內附範例程式碼) sample code ⭐C++ Makefile 相關文章整理⭐: 1. 【C++ Makefile】- 1 / 嘗試撰寫自己的第一份 Makefile 2. 【C++ Makefile】- 2 / 新增自己的變數 3. 【C++ Makefile】- 3 / Makefile 常用變數 -「$@」, 「$^」 4. 【C++ Makefile】- 4 / Makefile 常用 fake target -「.PHONY」
5. 【C++ Makefile】- 5 / Makefile 內建變數 -「$@」, 「$^」, 「$<」, 「$* 」,「$? 」
⭐【喜歡我的文章嗎? 歡迎幫我按讚~ 讓基金會請創作者喝一杯咖啡! 】
如果喜歡我的文章,請幫我在下方【按五下Like 】 (Google, Facebook 免註冊 ),會由 「LikeCoin 」 贊助作者鼓勵繼續創作,讀者們「只需幫忙按讚,完全不用出錢 」哦!