在第一篇我們已經學會如何編譯單一檔案的C++程式,接下來將介紹一些CMake的觀念 關於Targets 在CMake有兩種方式建立target,target的名稱必須是唯一的 add_executable(myexample simple.cpp) : 建立了一個名為myexample的target,並且命名輸出的執行檔為myexample add_library(mylibra...
Linux安裝prebuild函式庫以OpenCV為例
我的部落格文章轉錄–Linux環境撰寫Shared Library有詳細介紹如何製作和安裝Shared Library,如果想要了解更多Shared Library安裝和製作方式可以參考這篇。 在這篇我們想直接使用OpenCV預編譯的函式庫,省去自己編譯函式庫的時間,首先我們先到官網提到的Third-party packages的System packages in popular...
文章轉錄--Linux環境撰寫Shared Library
撰寫範例程式 bool isPalindrome(char* word); #include "pal.h" #include <string.h> bool isPalindrome(char* word) { bool ret = true; char *p = word; int len = strlen(word); char ...
Linux下設定VScode、CMake、GCC、GDB來開發C++專案
安裝套件 cmake extension c++ extension 安裝編譯器GCC、除錯器DBG sudo apt-get update sudo apt-get install build-essential gdb gcc -v #確認GCC安裝成功 注意: GDB 12.09 版本在VSCode除錯的時候會有錯誤,...
Ubuntu NTP 校時
timedatectl 時間管理工具 顯示目前的設定狀態 # 顯示目前狀態 timedatectl Local time: 三 2023-04-26 11:00:22 CST Universal time: 三 2023-04-26 03:00:22 UTC RTC tim...
CMake教學系列一使用CMake編譯專案
安裝最新版的CMake,越新越好,因為新版的CMake提供更多的工具幫你尋找函式庫或套件,尤其如果你需要用到CUDA,新版的CMake可以省去你許多的麻煩 安裝CMake Ubuntu可以跟著這篇官方教學安裝最新的CMake sudo apt-get update sudo apt-get install ca-certificates gpg wget test -f /us...
Ubuntu安裝軟體遇到Hash-mismatch錯誤
如果是在wsl,檢查一下nameserver設定,確認DNS伺服器有沒有正確設定。 https://geekdudes.wordpress.com/2022/11/16/windows-subsistem-for-linux-make-etc-resolv-conf-changes-permanent/ 在網路很糟的情況下可以重複apt update,有m...
update-alternatives管理軟體版本
update-alternatives --display cuda update-alternatives --config cuda 參考: https://www.baeldung.com/linux/update-alternatives-command https://then.tw/switch-gcc-versions-with-update-alternatives/
用bash讓程式壞掉的時候自動重啟
until myserver; do echo "Server 'myserver' crashed with exit code $?. Respawning.." >&2 sleep 1 done 參考: https://stackoverflow.com/a/697064/22299707
nohup使用教學
nohup command >logfile.txt 2>&1 & 參考 https://blog.csdn.net/xiaojin21cen/article/details/88991768