![錯誤:#error 此檔案需要編譯器和函式庫支援 ISO C++ 2011 標準](https://rvso.com/image/191772/%E9%8C%AF%E8%AA%A4%EF%BC%9A%23error%20%E6%AD%A4%E6%AA%94%E6%A1%88%E9%9C%80%E8%A6%81%E7%B7%A8%E8%AD%AF%E5%99%A8%E5%92%8C%E5%87%BD%E5%BC%8F%E5%BA%AB%E6%94%AF%E6%8F%B4%20ISO%20C%2B%2B%202011%20%E6%A8%99%E6%BA%96.png)
我正在使用某些叢集在 Ubuntu 20.04 LTS 上使用 TAU(分析和分析工具)運行 C++ 程式碼。我正在運行的命令如下所示:
tau_cxx.sh -I$FFTW3_INC wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -g" -o ../../Datasim/TauTest.out
然而,這給了我以下錯誤:
Executing> /opt/apps/gcc/5.2.0/bin/g++ -I/opt/apps/gcc5_2/mvapich22_2/fftw/3.3.8/include wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -o ../../Datasim/TauTest.out
In file included from /arcapps/cascades-broadwell-slurm/opt/apps/gcc/5.2.0/include/c++/5.2.0/cstdint:35:0,
from arithmeticFunctions.cpp:8:
/arcapps/cascades-broadwell-slurm/opt/apps/gcc/5.2.0/include/c++/5.2.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
make: *** [all] Error 1
所以我嘗試-std=c++11
像這樣編譯:
tau_cxx.sh -I$FFTW3_INC -std=c++11 wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -g" -o ../../Datasim/TauTest.out
這不知何故弄亂了我-I$FFTW3_INC
,我收到以下錯誤:
undefined reference to `fftw_malloc'
我也嘗試將其連結到我的 TAU 選項中,例如:
tau_cxx.sh -I$FFTW3_INC wrappingScript.cpp spectralFunctions.cpp arithmeticFunctions.cpp -optLinking="-lfftw3 -lm -std=c++11 -g" -o ../../Datasim/TauTest.out
這沒有任何效果,並給了我原來的錯誤。有人可以幫忙嗎我很困惑。
答案1
在添加(必需的)-std=c++11
標誌後(奇怪的是,現在的預設值是——即 ISO C++ 2017 + GNU 擴展——應該包括前面的),你可以編譯它,但是(大概在某個庫中)-std=gnu++17
的定義fftw_malloc
不見了。檢查手冊頁fftw_malloc
,它應該告訴你正確的咒語。如果這是從 a 呼叫的Makefile
,請檢查任何行LIB =
或類似的行。