当前位置: 首页 > 知识库问答 >
问题:

VScode无法正确连接到WSL

端木兴国
2023-03-14

我试图使用vscode连接到wsl,用CMAKE编译我的Fortran代码。当我试图配置我的项目时,cmake报告错误显示ifort无法编译一个简单的测试程序。完整的cmake输出如下所示:

[main] Building folder: program 
[main] Configuring folder: program 
[proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_Fortran_COMPILER:FILEPATH=/opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort -DCMAKE_C_COMPILER:FILEPATH=/opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/icc -H/home/user/program -B/home/user/program/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The Fortran compiler identification is Intel 2021.3.0.20210609
[cmake] -- Detecting Fortran compiler ABI info
[cmake] -- Detecting Fortran compiler ABI info - failed
[cmake] -- Check for working Fortran compiler: /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort
[cmake] -- Check for working Fortran compiler: /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort - broken
[cmake] CMake Error at /usr/local/lib/python3.8/dist-packages/cmake/data/share/cmake-3.21/Modules/CMakeTestFortranCompiler.cmake:54 (message):
[cmake]   The Fortran compiler
[cmake] 
[cmake]     "/opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: /home/user/program/build/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):/usr/bin/make -f Makefile cmTC_36220/fast && /usr/bin/make  -f CMakeFiles/cmTC_36220.dir/build.make CMakeFiles/cmTC_36220.dir/build
[cmake]     make[1]: Entering directory '/home/user/program/build/CMakeFiles/CMakeTmp'
[cmake]     Building Fortran object CMakeFiles/cmTC_36220.dir/testFortranCompiler.f.o
[cmake]     /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort    -c /home/user/program/build/CMakeFiles/CMakeTmp/testFortranCompiler.f -o CMakeFiles/cmTC_36220.dir/testFortranCompiler.f.o
[cmake]     Linking Fortran executable cmTC_36220
[cmake]     /usr/local/lib/python3.8/dist-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/cmTC_36220.dir/link.txt --verbose=1
[cmake]     /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/ifort CMakeFiles/cmTC_36220.dir/testFortranCompiler.f.o -o cmTC_36220 
[cmake]     ld: /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/../../bin/intel64/../../lib/icx-lto.so: error loading plugin: libimf.so: cannot open shared object file: No such file or directory
[cmake]     make[1]: *** [CMakeFiles/cmTC_36220.dir/build.make:99: cmTC_36220] Error 1
[cmake]     make[1]: Leaving directory '/home/user/program/build/CMakeFiles/CMakeTmp'
[cmake]     make: *** [Makefile:127: cmTC_36220/fast] Error 2
[cmake]     
[cmake]     
[cmake] 
[cmake]   
[cmake] 
[cmake]   CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:2 (project)
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/home/user/program/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/home/user/program/build/CMakeFiles/CMakeError.log".
[cmake] 

我的编译器是ifort Version2021.3.0.20210609,cmake是3.21.1,而wsl1是Ubuntu20.04。

code .

还有另外两条线索让我非常关注。首先,oneAPI需要用户添加

source /opt/intel/oneapi/setvars.sh

在。bashrc中初始化oneAPI环境。所以每次打开wsl终端时,它将首先显示:

:: initializing oneAPI environment ...
   -bash: BASH_VERSION = 5.0.17(1)-release
:: advisor -- latest
:: ccl -- latest
:: clck -- latest
:: compiler -- latest
:: dal -- latest
:: debugger -- latest
:: dev-utilities -- latest
:: dnnl -- latest
:: dpcpp-ct -- latest
:: dpl -- latest
:: inspector -- latest
:: intelpython -- latest
:: ipp -- latest
:: ippcp -- latest
:: itac -- latest
:: mkl -- latest
:: mpi -- latest
:: tbb -- latest
:: vpl -- latest
:: vtune -- latest
:: oneAPI environment initialized ::

在user@host之前。在vscode和wsl正常工作的计算机上,当我打开vscode并启动一个新的终端时,它显示

:: WARNING: setvars.sh has already been run. Skipping re-execution.
   To force a re-execution of setvars.sh, use the '--force' option.
   Using '--force' can result in excessive use of your environment variables.
ld: /opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64/../../bin/intel64/../../lib/icx-lto.so: error loading plugin: libimf.so: cannot open shared object file: No such file or directory

共有1个答案

景辰钊
2023-03-14

您能否尝试将以下shell脚本行添加到WSL Linux目标/etc/profile脚本中。此位置(或/etc/profile.d/脚本中)将确保WSL目标开发系统的所有用户在使用Visual Studio代码进行连接时都将运行setvars.sh环境脚本:

. /opt/intel/oneapi/setvars.sh &>/dev/null
 类似资料:
  • #用于连接jdbc的java代码 导入java。sql。*;公共类abc{ #我正在使用的驱动程序 #用popsql写的查询这是一个mysql查询 }

  • 问题内容: 我正在尝试使用Ruby on Rails运行Selenium的示例脚本。我必须使用代理运行它。这是我的代码: 我收到以下错误: 有人能帮我吗…?我已经尝试了好几个小时,却找不到问题…真的不知道该怎么办。 环境: Ubuntu 16.04 LTS,Firefox 45.0,rbenv 2.3.1 另一个问题:有人知道Selenium + Ruby on Rails的示例吗?我找不到真正好

  • 我正在尝试连接到MySQL服务器,但出现无法处理的错误。 java.sql.SQLNonTransientConnectionException:无法创建到数据库服务器的连接。尝试重新连接3次。放弃。com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)com.mysql.cj.jdbc.excepti

  • 我真的想不通为什么我不能用下面的代码连接到我的Django项目内的JQuery。你能告诉我是什么原因吗?多谢! null null

  • 我正在尝试使用Android studio提供的工具将我的Android应用程序连接到firebase,但我面临着很多麻烦。 我已经尝试更新依赖到最新的最新的谷歌服务,但错误仍然存在,显示的错误是无法解析Android应用模块的Gradle配置。解决分级生成问题和/或重新同步。 分级/应用程序a

  • 我正在开发Selenium,目前我有一个连接到两个运行linux和所有浏览器的虚拟机的集线器。 我能够启动浏览器,直到它突然停止。火狐或任何其他浏览器都不会启动。我得到以下错误。 45000 ms后无法连接到端口7055上的主机127.0.0.1。 我运行Selenium服务器独立2.26与火狐16.0.2. 请帮忙。