博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sublime text 2 c++编译 环境 问题小结
阅读量:6970 次
发布时间:2019-06-27

本文共 1816 字,大约阅读时间需要 6 分钟。

闲来无事,想要用subllime text 2 写下c++小程序,以前没用过这个编译c++,

期间出过很多问题,但是安装了sublime text 3 直接可以使用,前提安装了gcc/g++ 编译,没安装的去 安装下MinGW,然后在 环境变量把 MinGW下的bin 加入,

新建LIBRARY_PATH变量,如果有的话,在值中加入MinGW下的lib;新建C_INCLUDEDE_PATH变量,值设为MinGW下的include。

不过本着找问题解决问题,查了不少,最终成功在sublime text 2上跑起来了c++ 

 

其中遇到

1.Sublime Text 2 编译c++没反应

去找C:\Users\Administrator\AppData\Roaming\Sublime Text 2\Packages\Default下的 exec.py中修改

os.environ["PATH"] =os.path.expandvars(path).encode(sys.getfilesystemencoding())

看一下你的exec.py的 40行是不是这个

45行 换成 proc_env[k] = os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())

2.让Sublime text 2 的build系统支持中文路径和中文文件

Sublime text 2的build系统不支持中文路径,可以通过如下方式解决:

打开sublime_plugin.py文件(可以用Everything搜索)

添加以下内容:

reload(sys)

sys.setdefaultencoding('gbk')

3.Ctrl+shift+B 无法运行 

去C:\Users\Administrator\AppData\Roaming\Sublime Text 2\Packages\C++\C++.sublime-build

修改

// "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]

"cmd" : ["${file_path}/${file_base_name}"]

然后就可以正常运行了

 

4.Decode error - output not utf-8

去找C:\Users\Administrator\AppData\Roaming\Sublime Text 2\Packages\Default下的 exec.py中修改

修改append_data 方法下的替换部分加粗部分

def append_data(self, proc, data):

if proc != self.proc:
# a second call to exec has been made before the first one
# finished, ignore it instead of intermingling the output.
if proc:
proc.kill()
return

is_decode_ok = True;

try:
str = data.decode(self.encoding)
except:
is_decode_ok = False
if is_decode_ok==False:
try:
str = data.decode("gbk")
except :
str = "[Decode error - output not " + self.encoding + "and gbk]\n"
proc = None

# Normalize newlines, Sublime Text always uses a single \n separator

# in memory.
str = str.replace('\r\n', '\n').replace('\r', '\n')

 

 

转载于:https://www.cnblogs.com/liumianweifeng/p/3854853.html

你可能感兴趣的文章
《Android Security Internals》第二章权限翻译
查看>>
笔者介绍
查看>>
spring-cloud Sleuth
查看>>
大数据成神之路
查看>>
重新梳理下js中的深拷贝和浅拷贝
查看>>
个推Node.js 微服务实践:基于容器的一站式命令行工具链
查看>>
Taro 多端开发的正确姿势:打造三端统一的网易严选(小程序、H5、React Native)...
查看>>
105. Construct Binary Tree from Preorder and Inorder Traversal
查看>>
Data Lake Analytics: 以SQL方式查询Redis数据
查看>>
elasticsearch v6.5.4配置
查看>>
关于分块思想的个人理解
查看>>
手机端车牌号码键盘的vue组件
查看>>
iOS App卡顿监控(Freezing/Lag)
查看>>
云HBase发布全文索引服务,轻松应对复杂查询
查看>>
leetcode394. Decode String
查看>>
我们如何在Linkerd 2.2里设计重试
查看>>
Java程序员月薪达到三万,需要技术水平达到什么程度?
查看>>
cross-env使用
查看>>
web移动端与Hybird开发知识整理
查看>>
用最新的 Alamofire(swift 4.1) (带参数)post方法上传图片到服务器
查看>>