錯誤信息:bash
ld: library not found for -lflann_cpp clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [bshot] Error 1 make[1]: *** [CMakeFiles/bshot.dir/all] Error 2 make: *** [all] Error 2
解決方案:spa
第一步,本身找到這個庫code
庫通常放在系統默認處或者安裝到特定地方。blog
Linux 系統默認庫放在:it
/lib
/usr/lib
/usr/local/lib
...
安裝到特定地方,如我 Mac 的用 Homebrew 安裝到:io
/usr/local/Cellar/flann/1.9.1_6/libclass
第二步:添加路徑
系統級:修改/etc/profile
或者/etc/bashrc
gcc
用戶級:修改~/.bashrc
或者~/.bash_profile
file
#添加到gcc頭文件 export C_INCLUDE_PATH=$C_INCLUDE_PATH:/MyLib #添加到g++頭文件路徑 export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/MyLib #添加到動態庫 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/MyLib #添加到靜態庫 export LIBRARY_PATH=$LIBRARY_PATH:/MyLib