这是我在单击 Project->Clean 菜单时在 Console 中看到的内容:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hw.o ..\src\hw.cpp
g++ -ohw.exe src\hw.o
但我不知道这些命令是如何生成的?
有人可以详细说明命令的生命周期吗?
这是 .project
文件:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hw</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/hw/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
最佳答案
在文本编辑器中打开 Debug/makefile 或 Release/makefile。它包含您在控制台窗口中看到的命令。此外,当您进行 Clean 而不是常规构建时,会执行 clean 部分。
一般情况下,CDT会根据项目的属性,为项目中的所有源文件生成makefile。然后它使用带有可选参数的命令 make 执行 makefile。您可以通过在 Debug 或 Release 目录中的命令行执行 make 命令来执行相同的操作。
从命令行看,它看起来像这样:
alex@alex-linux:~/workspace/Test/Debug$ make clean rm -rf ./main.o ./main.d Test alex@alex-linux:~/workspace/Test/Debug$ make Building file: ../main.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp" Finished building: ../main.cpp Building target: Test Invoking: GCC C++ Linker g++ -o"Test" ./main.o Finished building target: Test
关于c++ - IDE 中的更多内容(eclipse cdt),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2513831/