1. 程式人生 > 實用技巧 >mmdetection踩坑記錄 error: command 'g++' failed with exit status 1

mmdetection踩坑記錄 error: command 'g++' failed with exit status 1

最近在搭建一個基於基於mmdetection的一個環境,遇到了各種gcc g++問題:

1.''ImportError: ***/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/../../../libstdc++.so.6: version `CXXABI_1.3.11' not found (required by /DB/rhome/yuhangzhou/miniconda3/envs/open-mmlab/lib/python3.7/site ackages/torch/lib/libtorch_python.so)'',

解決辦法:

then i remove original libstdc++.so.6
, and run ''ln -s libstdc++.so.6.0.26 libstdc++.so.6'' after that, i run '''python setup.py develop' again,

2.error: command 'g++' failed with exit status 1

/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lm
/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lpthread


/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lc
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1

這個bug找了很多部落格,都說是讓安裝g++,但是我是在伺服器上搭環境,沒有root許可權

偶然間在下面連線中找到了解決辦法:

https://stackoverflow.com/questions/47512182/cannot-find-lfftw3-omp-error-when-compiling-a-third-party-package-how-to-lin

解決方法是找到包含-lm、-lpthread、-lc的檔案,並將其連線到所需的資料夾下

以-lpthread為例:

(1)在終端中輸入指令:ld -lpthread --verbose

找到succeeded路徑,作為path 1

如上圖的中path 1可以為/usr/lib/x86_64-linux-gnu/libpthread.so

(2)然後從錯誤資訊:/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lpthread

中獲得path 2=/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/

(3)最後在終端中輸入指令:

ln -spath 1path 2

(4)用類似的方法分別處理-lm、-lc

執行編譯程式python setup.py develop 或 bash compile.sh

示例:ln -s /usr/lib/x86_64-linux-gnu/libpthread.so /home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/

注:過程中會出現很多wanring,大約10分鐘

但是結果會出現finished