一、问题描述
一个炎热的下午,笔者登上许久未使用的服务器,正准备运行一个N久没运行过的代码,为了保证可执行文件是新编译出的,笔者敲下make
,点击回车,哎,一个奇怪的错误出现了:
icpc: error #10417: Problem setting up the Intel(R) Compiler compilation environment. Requires 'install path' setting gathered from 'g++'
看内容好像是设置英特尔编译器编译环境时出现了问题,还和g++有关,这意味着icpc和icc都不能用了,不过笔者快速的确定了关键信息icpc: error #10417
,直接来到Intel社区[1]搜索一番。
二、解决方案
找到一个和我报错一致的帖子[2],根据一位名为VidyalathaB_Intel
的用户的描述,问题产生的原因如下:
One of the reasons that may cause this error is, changing the PATH environment variable. If you change that, the shell doesn't find the program (here it is g++).
So please check if the g++ executable file location is present in the PATH environment variable.
可能导致此错误的原因之一是更改 PATH 环境变量。如果你改变它,shell 就找不到程序(这里是 g++)。
因此,请检查 PATH 环境变量中是否存在 g++ 可执行文件位置。
意思就是说PATH
环境变量中找不到g++的可执行文件位置了,不知道系统的环境被谁搞乱了,现在有两种方案,一是找到g++可执行文件位置,并添加到PATH
环境变量中,二是重装g++,系统会自动添加g++对应的环境变量到PATH
,笔者采取的解决方案为后者(原以为一行命令就可以解决,结果用了4行命令😐)。
-
执行
sudo apt install build-essential
build-essential
软件包[3]可以安装Ubuntu编译C/C++的环境,一键安装。
出现以下提示:Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: build-essential : Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
提示:
以下包具有未满足的依赖关系
那就手动安装这个dpkg-dev
-
执行
sudo apt install dpkg-dev
又出现以下提示:Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: dpkg-dev : Depends: libdpkg-perl (= 1.19.0.5ubuntu2.4) but 1.19.7ubuntu3 is to be installed Recommends: build-essential but it is not going to be installed E: Unable to correct problems, you have held broken packages.
出现了,多层依赖关系!
根据以往的经验,我选择remove
-
执行
sudo apt-get remove libdpkg-perl
成功!
-
再次执行
sudo apt install build-essential
好,安装成功,接下来测试一下。
-
执行
g++ --version
和gcc
和g++
root@ln01:/home/tangjiahao# g++ --version g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@ln01:/home/tangjiahao# gcc gcc: fatal error: no input files compilation terminated. root@ln01:/home/tangjiahao# g++ g++: fatal error: no input files compilation terminated.
现在系统已经可以找到gcc和g++的可执行文件了。
-
编译我自己的程序,执行
make
tangjiahao@ln01:~/paper-kmax/my_ktruss$ make icpc -fopenmp -O3 -std=c++14 -o kmtruss kmax_truss.cpp tangjiahao@ln01:~/paper-kmax/my_ktruss$
成功!
三、总结
以上就是今天解决BUG的过程😯。
如果本文能给你带来帮助的话,点个赞鼓励一下作者吧!😁
四、引用参考
[1] Intel社区 https://community.intel.com/
[2] icpc: error #10417: Problem setting up the Intel® Compiler compilation environment. https://community.intel.com/t5/Intel-C-Compiler/icpc-error-10417-Problem-setting-up-the-Intel-R-Compiler/td-p/1324978
[3] 软件包: build-essential https://packages.ubuntu.com/bionic/build-essential