在您配置的INTEL C ++编译器(Linux)的搜索路径中找不到可执行文件 [英] Can't find file executable in your configured search path for INTEL C++ compiler (Linux)

查看:807
本文介绍了在您配置的INTEL C ++编译器(Linux)的搜索路径中找不到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用code :: blocks调试我的c ++代码。我打开一个新项目并粘贴我的代码。但是上面有错误。老实说,我不确定我的编译器是什么!当我想运行我的代码时,我写:

I want to debug my c++ code using code::blocks. I open a new project and paste my code. But there is above error. To be honest, I'm not sure what is my compiler! when I want to run my code, I write:

g++ -std=gnu++11 mycodename.cpp

在终端中。
如何删除Linux中的上述错误?
一个逐步的答案是高度赞赏的。
我将编译器从 setting ... compiler 更改为gnu gcc,但错误与intel编译器有关!

in the terminal. How can I remove above error in Linux? A step by step answer is highly appreciated. I change the compiler from setting...compiler to gnu gcc but the error is about intel compiler!

推荐答案


我想使用code :: blocks调试我的c ++代码。

I want to debug my c++ code using code::blocks.

不要,因为你做不到。

代码::块只是一个 IDE ,它是一些能够运行编译器和调试器的源代码编辑器。所以Code :: Blocks是 not 的编译器,而不是的调试器(但它可以运行它们)。

Code::Blocks is just an IDE, that is it is some source code editor capable to run compilers and debuggers. So Code::Blocks is not a compiler and is not a debugger (but it could run them).

我不会解释您如何使用Code :: Blocks。它有一些文档和一些论坛。我宁愿尝试解释如何调试C ++代码。

I won't explain how you might use Code::Blocks. It has some documentation and some forum. I will rather try to explain how you should debug your C++ code.

首先,您使用 GCC 进行编译(它是编译器,更确切地说是 GNU编译器集合;您将在 g ++ 程序来编译C ++代码,用 gcc 来编译C代码,等等。) 阅读有关调用GCC 的章节。

First, you compile with GCC (it a compiler, more precisely the GNU Compiler Collection; you'll use it with g++ program to compile C++ code, with gcc to compile C code, etc....). Read the chapter about Invoking GCC.

要编译由单个 C ++组成的简单C ++程序翻译单元(一个C ++文件 yoursourcecode.cpp 包括一些标头)到可执行文件 yourprog 使用:

To compile a simple C++ program made of a single C++ translation unit (a C++ file yoursourcecode.cpp including some headers) into an executable yourprog use:

 g++  -std=gnu++11 -Wall -Wextra -g yoursourcecode.cpp -o yourprog

请注意:


  • g ++ 的程序参数顺序很重要。

  • order of program arguments to g++ are important.

-std = gnu ++ 11 定义您的C ++方言

-std=gnu++11 defines your C++ dialect

-Wall- Wextra 询问所有警告以及其中的一些警告。您真的想要警告。然后,您需要改进源代码以完全不发出警告,并重复编译。

-Wall -Wextra asks for all warnings and some extra of them. You really want warnings. You then need to improve your source code to get no warnings at all and repeat the compilation.

-g 询问调试信息(格式为 DWARF 格式)。您希望能够进行调试。

-g ask for debug info (in DWARF format). You want to be able to debug.

-o yourprog 要求编译器生成输出 yourprog ELF 可执行文件

-o yourprog asks the compiler to generate as output the yourprog ELF executable

BTW,您不能使用Code :: Blocks来编译代码。您可以配置它以运行上面的命令来编译它。

BTW, you cannot use Code::Blocks to compile your code. You could configure it to run the above command to compile it.

如果您的程序是由几个 C ++源文件(以及几个翻译单元)组成的),您需要将每个翻译单元编译为目标文件,然后编译为链接可以使它们成为可执行文件。因此,使用两个源文件 yourfirstsource.cpp yoursecondsource.cpp ,您需要运行:

If your program is made of several C++ source files (and several translation unit) you need to compile every translation unit into an object file, and then to link these to make your executable. So with two source files yourfirstsource.cpp and yoursecondsource.cpp you need to run:


  • g ++ -Wall -Wextra -g -c yourfirstsource.cpp -o yourfirstsource.o 编译第一个 yourfirstsource.cpp 放入 yourfirstsource.o 对象文件。

  • g ++ -Wall -Wextra -g -c yoursecondsource.cpp -o yoursecondsource.o 来编译第二个翻译单元。

  • g ++ yourfirstsource.o yoursecondsource.o -o yourprog 将两个目标文件链接到一个可执行文件中。您可以使用 -L dir -l <​​/ code> libname 链接库em>参数(顺序很重要,从更高级别的库到最低级别的库很重要)

  • g++ -Wall -Wextra -g -c yourfirstsource.cpp -o yourfirstsource.o to compile the first yourfirstsource.cpp into the yourfirstsource.o object file.
  • g++ -Wall -Wextra -g -c yoursecondsource.cpp -o yoursecondsource.o to compile the second translation unit.
  • g++ yourfirstsource.o yoursecondsource.o -o yourprog to link both object files into an executable. You might link libraries with -Ldir and -llibname arguments (order is important, from higher level to lowel level libraries)

实际上,如果您有多个C ++文件,最好使用一些构建自动化工具,例如 GNU make 忍者。该工具将运行上述编译和链接命令。 您应该能够在命令行上进行编译(和链接)

In practice, if you have several C++ files, you'll better use some build automation tool, like GNU make or ninja. That tool will run compilations and link commands like above. You should be able to compile (and link) on the command line.

一旦有了带有调试信息的可执行文件,就可以使用 gdb 调试器。 阅读使用GDB调试文档。我强烈建议在终端中使用 gdb 。用 gdb ./yourprog (或 gdb -tui ./yourprog 如果需要终端接口)启动它,然后您会收到(gdb)提示符,然后可以键入调试器命令。最有用的是 run (或 r ), break (或 b ),列表(或 l ) ,打印(或 p ), backtrace (或 bt )。

Once you have an executable with debug info, you can use the gdb debugger. Read the Debugging with GDB documentation. I strongly recommend using gdb in a terminal. Start it with gdb ./yourprog (or gdb -tui ./yourprog if you want a terminal interface), then you get a (gdb) prompt and you can type debugger commands. The most useful ones are run (or r), break (or b), list (or l), print (or p), backtrace (or bt).

如果您想直接运行程序,请输入其文件路径,例如 ./ yourprog 在命令中(即某些终端)。请注意浏览

If you want to run your program directly, type its file path, e.g. ./yourprog in a command (i.e. some terminal). Be aware of globbing.

出于基准测试的目的,最好让您的 g ++ 编译器使用使用 -O1 -O2 等进行优化

For benchmarking purposes, it is better to ask your g++ compiler to optimize with -O1 or -O2 etc.

该工具是一个编辑器,也能够运行 g ++ 编译和上面的 gdb 调试命令。但您确实需要熟悉命令行上的这些 g ++ gdb 工具。完成此操作后,进入 Code :: Blocks文档 了解如何配置您的源代码编辑器(顺便说一下,我的首选是 emacs )。

That tool is an editor, also able to run the g++ compilation and gdb debugging commands above. But you really need to become familar with these g++ and gdb tools on the command line. Once you can do that, dive into the Code::Blocks documentation to understand how to configure your source code editor (BTW my preference is emacs).

Code :: Blocks无法编译代码或调试程序。它只是运行外部程序(例如 g ++ 编译器或 gdb 调试器),但您应该首先学习自己使用 g ++ gdb (在Code :: Blocks或任何其他源代码编辑器之外)。

Code::Blocks is not able to compile your code or debug your program. It is just running external programs (such as the g++ compiler or the gdb debugger), but you should first learn to use g++ and gdb by yourself (outside of Code::Blocks or any other source code editor).

BTW,英特尔制造了专有的C ++编译器(听说它叫做 icc ,您可能需要为此付费)。还有 Clang / LLVM ,它是(开源或)免费软件(例如 GCC 是,但许可不同。它的 clang ++ 程序接受与 g ++ 类似的参数。在许多情况下,您只需将 g ++ 替换为 clang ++ 即可使用该Clang编译器。

BTW, Intel makes a proprietary C++ compiler (I heard it is called icc, and you might need to pay for it). And there is also Clang/LLVM, which is (open source or) free software (like GCC is, but with a different license). Its clang++ program accepts arguments similar to those for g++. In many cases you could simply replace g++ by clang++ to use that Clang compiler.

还要注意 $ PATH 变量。您需要配置外壳程序(也许您的〜/ .bashrc )进行更改。

Be also aware of the $PATH variable. You'll need to configure your shell (perhaps your ~/.bashrc) to change it.

我强烈建议您学习如何使用某些版本控制系统工具,例如 git (具有良好的视频和文档,功能非常强大)。

I strongly recommend to learn how to use some version control system tool, like git (which has good videos and documentation and is very powerful).

这篇关于在您配置的INTEL C ++编译器(Linux)的搜索路径中找不到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆