簡體   English   中英

如何在 Sublime Text 的構建系統中使用 Mingw

[英]How to use Mingw with a build system in Sublime Text

我正在使用 Sublime Text 並學習 C++。 我安裝了 Mingw(也添加了路徑)和 Sublime Text,並添加了一個新的構建系統來獲取外部輸出和輸入。

這是代碼:

{
    "cmd" : ["g++ -std=c++14 '$file_name' -o '$file_base_name' && timeout 4s ./'$file_base_name'<input.txt>output.txt"], 
    "selector" : "source.c, source.cpp",
    "shell": true,
    "working_dir" : "$file_path"
}

Control + B 后,它拋出了一個錯誤:

c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe:D:\Anand\competitive programming\input.txt: file format not recognized; treating as linker script
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe:D:\Anand\competitive programming\input.txt:1: syntax error
collect2.exe: error: ld returned 1 exit status
[Finished in 0.1s with exit code 1]
[shell_cmd: g++ "D:\Anand\competitive programming\input.txt" -o "D:\Anand\competitive programming/input" && "D:\Anand\competitive programming/input"]
[dir: D:\Anand\competitive programming]
[path: C:\MinGW\bin;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\MinGW\bin]

Error 2:

The system cannot find the path specified.
[Finished in 0.0s with exit code 1]
[cmd: ["g++ -std=c++14 'HelloWorld.cpp' -o 'HelloWorld' && timeout 4s ./'HelloWorld'<input.txt>output.txt"]]
[dir: D:\Anand\competitive programming]
[path: C:\MinGW\bin;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\MinGW\bin]

您不需要圍繞$變量的單引號,也不需要./ ,因為您正在運行 Windows。 編輯您的構建系統以包含以下內容:

"cmd" : ["g++ -std=c++14 $file_name -o $file_base_name && timeout 4s $file_base_name < input.txt > output.txt"],

你應該准備好了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM