Ubuntu下Meson构建CUDA项目测试时提示找不到mono的问题
Linux下Meson运行CUDA项目测试触发mono错误的原因与解决
在Ubuntu系统上使用Meson构建小型CUDA项目,构建脚本如下:
project('cuda_project', 'cuda', default_options: [ 'cpp_std=c++17', 'cuda_ccbindir=/usr/bin/g++-11', ], ) cuda_compiler = meson.get_compiler('cuda') exe = executable( 'main.exe', 'main.cu', link_args: '-fopenmp', cuda_args: '-Xcompiler=-fopenmp', ) test('simple_run', exe)
编译流程正常,但执行meson test -c builddir时,Meson抛出错误:
FileNotFoundError: [Errno 2] No such file or directory: 'mono'
问题出在可执行文件的命名上——你把输出文件命名为main.exe,Linux环境下Meson会根据.exe后缀判断这是Windows可执行文件,自动尝试调用mono运行它,而你的系统里没装mono,所以触发了找不到文件的错误。
解决方法很简单,把可执行文件的名字改成不带.exe的形式,比如main:
exe = executable( 'main', 'main.cu', link_args: '-fopenmp', cuda_args: '-Xcompiler=-fopenmp', )
重新构建后再运行测试就能正常执行了。
内容的提问来源于stack exchange,提问作者tornikeo
相关产品推荐
相关产品推荐

