Build error: C++ compiler produced errors. See the Build Log for further details.

10 次查看(过去 30 天)
Hello, I wanted to create a MEX file in MATLAB, but I couldn't do that because of the following message in the "build log":
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "BPmimo2C_data.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
BPmimo2C_data.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "BPmimo2C_initialize.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
BPmimo2C_initialize.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "BPmimo2C_terminate.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
BPmimo2C_terminate.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "BPmimo2C.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
BPmimo2C.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "interface/_coder_BPmimo2C_info.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
_coder_BPmimo2C_info.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "interface/_coder_BPmimo2C_api.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
_coder_BPmimo2C_api.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "interface/_coder_BPmimo2C_mex.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
_coder_BPmimo2C_mex.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "MWCudaDimUtility.cu"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
MWCudaDimUtility.cu
nvcc -c -rdc=true -Xcompiler "/wd 4819" -Xcompiler "/MD" -Xcudafe "--diag_suppress=unsigned_compare_with_zero --diag_suppress=useless_type_qualifier_on_return_type" -D_GNU_SOURCE -DMATLAB_MEX_FILE -Wno-deprecated-declarations     -arch sm_35 -I "C:\PROGRA~1\MATLAB\R2018b\simulink\include" -I "C:\PROGRA~1\MATLAB\R2018b\toolbox\shared\simtargets" -I "D:\feko\multiple ring array\codegen\mex\BPmimo2C" -I "D:\feko\multiple ring array" -I ".\interface" -I "C:\PROGRA~1\MATLAB\R2018b\extern\include" -I "." "cpp_mexapi_version.cpp"
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
cpp_mexapi_version.cpp
nvcc -m64 -Wl,--no-undefined -shared -static -L"C:\Program Files\MATLAB\R2018b\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -llibMatlabDataArray -llibMatlabEngine -Xnvlink -w -Wno-deprecated-gpu-targets -Xlinker /NODEFAULTLIB:libcmt.lib -o BPmimo2C_mex.mexw64 -arch sm_35 BPmimo2C_data.obj BPmimo2C_initialize.obj BPmimo2C_terminate.obj BPmimo2C.obj _coder_BPmimo2C_info.obj _coder_BPmimo2C_api.obj _coder_BPmimo2C_mex.obj MWCudaDimUtility.obj cpp_mexapi_version.obj -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib\x64" cuda.lib cudart.lib cublas.lib cusolver.lib cufft.lib -Xlinker libemlrt.lib,libcovrt.lib,libut.lib,libmwmathutil.lib,/export:mexFunction,/export:emlrtMexFcnProperties 
nvcc fatal : Unknown option '-Wl,--no-undefined'
gmake: *** [BPmimo2C_mex.mexw64] Error 1
Warning: Selected MEX compiler 'MinGW64 Compiler (C++)' is not supported for GPU code generation. Refer to the GPU Coder documentation for a list of supported GPU MEX compilers. 
> In coder.gpu.getDefaultGpuToolchain
  In emlckernel
  In emlckernel
  In emlcprivate
  In coder.internal.gui.codegenWrapper
  In codeUnifiedProject
  In codeUnifiedProject
  In emlcprivate 
??? Build error: C++ compiler produced errors. See the Build Log for further details.
Code generation failed: View Error Report
I have previously installed visual studio 2019, and added the "cl.exe" path to my environmental variable. Moreover, Microsoft visual C++ redistributable x64 2015-2019 is currently available on my system.
Here is the added path:
What do you think about where my problem come from?
Any help would be appreciated.
Thank you

采纳的回答

Chao Luo
Chao Luo 2024-6-25
You are using MinGW64 as the C++ compiler, which is not supported by nvcc. You can config it using:
mex -setup c++
and select Microsfot Visual C++ 2019.
  6 个评论
Chao Luo
Chao Luo 2024-6-28
Seems you are using MATLAB 2018b. It does not support Visual Studio 2019 because it was not released when MATLAB 2018b was released. VS 2017 should be supported.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by