在linux下无需配置即可让ST用gcc进行编译。在windows下如果使用vs2012的cl编译工具就要折腾一番了。
首先是安装vs2012(废话)。
然后是配置环境变量。比较推荐在“用户变量”里编辑,首先是PATH
1
|
C
:
\
Program
Files
(
x86
)
\
Microsoft
Visual
Studio
11.0
\
VC
\
bin
;
C
:
\
Program
Files
(
x86
)
\
Microsoft
Visual
Studio
11.0
\
Common7
\
IDE
|
然后添加INCLUDE
1
|
C
:
\
Program
Files
(
x86
)
\
Microsoft
Visual
Studio
11.0
\
VC
\
include
;
C
:
\
Program
Files
(
x86
)
\
Microsoft
SDKs
\
Windows
\
v7
.
1A
\
Include
;
C
:
\
Program
Files
(
x86
)
\
Windows
Kits
\
8.0
\
Include
|
最后是最关键的LIB
1
|
C
:
\
Program
Files
(
x86
)
\
Microsoft
Visual
Studio
11.0
\
VC
\
lib
;
C
:
\
Program
Files
(
x86
)
\
Microsoft
SDKs
\
Windows
\
v7
.
1A
\
Lib
|
。网上很多教程在lib这一项都少了
1
|
C
:
\
Program
Files
(
x86
)
\
Microsoft
SDKs
\
Windows
\
v7
.
1A
\
Lib
|
因为他们是vs2010的环境,与vs2012不一样吧,这些路径都依据自己的系统而定。
接下来就是ST2的编译配置了,tools->build system->new build system
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
{
"cmd"
:
[
"CL"
,
"/EHsc"
,
"/Fo${file_base_name}"
,
"/O2"
,
"${file}"
]
,
"file_regex"
:
"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$"
,
"working_dir"
:
"${file_path}"
,
"selector"
:
"source.c, source.c++"
,
"encoding"
:
"cp936"
,
"variants"
:
[
{
"name"
:
"Run"
,
"cmd"
:
[
"callrun.bat"
,
"${file_base_name}.exe"
]
}
]
}
|
然后在c:windows 或者其他path环境变量路径里新建两个.bat文件
1
2
3
4
5
6
|
run
.
bat
@
echo
off
%
1
pause
exit
|
1
2
3
|
callrun
.
bat
@
echo
off
start
run
.
bat
%
1
|
这样调整之后就可以正常弹出控制台了。
但是还是有一个问题是如果文件名为6.1.1.cpp,能正常生成6.1.1.exe但是弹出的控制台提示无法打开。这与.是分不开的。目前我还不知道怎么解决。文件名里不带.应该也算一个解决方案。