且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在代码块中的.cpp文件中创建.exe?

更新时间:2022-03-19 04:58:00

从查看更新的构建日志,似乎没有执行链接步骤来生成最终的可执行文件。有几件事你可以检查和一些想法尝试:

From looking at your updated build log, it appears the linking step isn't being performed to generate the final executable. There are a couple of things you can check and some ideas to try out:


  • 确保链接器可执行文件和正确的路径设置为C :: B可以找到它。对于MinGW,链接器通过名为g ++。exe的编译器驱动程序调用。

  • 检查是否选择了控制台应用程序下类型。

  • 如果一切看起来还好,但它仍然请尝试创建一个新的空白控制台项目。

  • 尝试从cmd命令提示符处手动构建,以确保工具链本身正常工作。你应该在你的mingw安装下找到一个'mingwvars.bat'脚本。运行该脚本以打开正确的命令行环境。使用此命令进行简单测试编译:

  • Make sure the linker executable and proper path is set so C::B can locate it. For MinGW the linker is invoked through the compiler driver named 'g++.exe'.
  • Check that 'Console application' is selected under 'Type'.
  • If everything looks okay but it still doesn't link try creating a new blank console project. Add the existing files to that project and try building it.
  • Try building it manually from a 'cmd' command prompt to make sure the toolchain itself is functioning. You should find a 'mingwvars.bat' script under your mingw install. Run that script to open up a proper commandline environment. Do a simple test compile using this command:

cdD:\ My Documents \0HOME \Programming\C ++ \Code Blocks\cplusplus.com教程

g ++。exe -Wall -g Variables.cpp -o Variables.exe

cd "D:\My Documents\0HOME\Programming\C++\Code Blocks\cplusplus.com Tutorial"
g++.exe -Wall -g Variables.cpp -o Variables.exe

最后,这是你的日志应该大致看起来当它正确建立:

Lastly, this is what your log should approximately look like when it's building correctly: