gpt4 book ai didi

c - Sublime Text 3,GCC 构建系统问题

转载 作者:行者123 更新时间:2023-11-30 16:39:26 25 4
gpt4 key购买 nike

在构建工作的“.c”代码文件时,我在使用要构建的菜单图标构建时遇到错误(构建系统 GCC)

当我导航时:工具 -> 构建(选择 GCC 作为构建系统)

'main.exe' is not recognized as an internal or external command,
operable program or batch file.
[Finished in 0.1s with exit code 1]
[cmd: ['main.exe']]
[dir: C:\Users\erik\Documents\Carleton University\Sysc 2006\Lab 11\Recursion\Recursion]
[path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;C:\Perl64\site\bin;C:\Perl64\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\MinGW\bin;C:\MinGW\mingw32\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\PharosSystems\Core;C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\erik\AppData\Local\bin\NASM;C:\Program Files\Git\cmd;C:\Users\erik\AppData\Local\Microsoft\WindowsApps;C:\altera\13.0sp1\modelsim_ase\win32aloem;C:\Users\erik\AppData\Local\GitHubDesktop\bin;]

但是如果我导航:工具 -> 命令面板 -> 使用:GCC 构建

[Finished in 0.5s]

按照上面这个受人喜爱的视觉效果,我将导航:工具 -> 构建(选择 GCC 作为构建系统),或者工具 -> 命令面板 -> 构建:GCC -RUN

***Expected working output***

这是我的 GCC.sublime-build 文件,我怀疑这是导致问题的文件。

// Put this file here:
// "C:\Users\[User Name]\AppData\Roaming\Sublime Text 3\Packages\User"
// Use "Ctrl+B" to Build and "Crtl+Shift+B" to Run the project.
// OR use "Tools -> Build System -> New Build System..." and put the code there.
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe"],

// Doesn't work, sublime text 3, Windows 8.1
// "cmd" : ["gcc $file_name -o ${file_base_name}"],

"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path",

// You could add path to your gcc compiler this and don't add path to your "PATH environment variable"
// "path" : "C:\\MinGW\\bin"

"variants" : [

{ "name": "Run",
"cmd" : ["${file_base_name}.exe"]
}
]
}

虽然问题可能就在这里,但我非常担心它也可能在其他地方,因为我一直在努力实现库。第二个问题是为什么我的“Path:”变量这么长,它是否不必要地长?其中许多在 Sublime 中是不需要的,对吗?

最佳答案

这将允许您在 sublime 以及命令提示符中编译和运行 C++ 程序

{
"shell_cmd": "g++ -Wall -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}.exe\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",

"variants":
[ // to run in the sublime text console
{
"name": "Run",
"shell_cmd":"\"${file_path}/${file_base_name}\""
},
// to run in the Windows command line
{
"name": "Run in cmd",

"shell_cmd": "start cmd /k $file_base_name "

}
]}

关于c - Sublime Text 3,GCC 构建系统问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47063454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com