Sublime Text 2 and MinGW

家住魔仙堡 提交于 2020-01-01 03:29:07

问题


Good day!

Can anyone share their experience how to attach MinGW-compiler to Sublime?

I found a config in the internet, but when I run compiled program popping bugs with missing files from "../MinGW/bin/".

Config:

{
   "cmd": ["mingw32-g++.exe", "-o", "$file_base_name", "$file_name"],
   "path": "c:\\Program Files\\MinGW\\bin\\"
}

Thanks!

UPD

I found answer for my question! I had to add one parameter in cmd. It's "-static".

So, it's my MinGW.sublime-build, which works fine:

{
    "path": "c:\\Program Files\\MinGW\\bin\\",
    "cmd": ["mingw32-g++.exe", "-static", "-o", "$file_base_name", "$file"]
}

回答1:


Make sure to include the bin file in the "Path" variable on your system.

Open the start menu and type "variable" or "environment variable" (or google it) to find how to do it. You'll get in a Window with a lot of variables, find the Path (and not PATH) variable and add the path to the bin folder of MinGW.

And btw, as suggested, you should change file_base_name by file, and put file_base_name where you put file_base.

Here's the command I personally use:

"cmd": ["C:\\MinGW\\bin\\mingw32-g++.exe", "-Wall", "-time", "$file", "-o", "$file_base_name"]




回答2:


You should be using $file instead of $file_name. $file_name expands to only the name whereas $file expands to the full path.

The changed config would be

{
   "cmd": ["mingw32-g++.exe", "-o", "$file_base_name", "$file"],
   "path": "c:\\Program Files\\MinGW\\bin\\"
}


来源:https://stackoverflow.com/questions/11627977/sublime-text-2-and-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!