如何运行和崇高文本2编译.C [MAC OS X] [英] How to Run and Compile .c on Sublime Text 2 [MAC OS X]

查看:113
本文介绍了如何运行和崇高文本2编译.C [MAC OS X]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在大学学习C,现在,老师告诉我使用$ C $个cblocks作为一个IDE,但是在我看来,$ C $的cblock是有点难看,这就是为什么我选择了崇高的文本2,最佳IDE /文本编辑器在那里。

I am learning C at college now, and teachers told me to use codeblocks as an IDE, but in my opinion codeblocks is a bit ugly and that's why I've chosen Sublime Text 2, the BEST IDE/Text Editor out there.

目前我通过崇高写我的code的瞬间,将其保存,然后通过MAC OS终端(GCC)编译它,比在终端上运行它,以及...

At the moment I write my code via sublime, save it and then compile it via mac os terminal (gcc) and than run it on the terminal as well...

我想知道的,如果它甚至有可能,是怎么做是正确的,从壮美,利用其控制台或插件(或其它),换句话说,我想知道是否可以编译我。 c和右的崇高仅电子邮件点击几下运行它......(现在我只是建立控制台应用程序)

What I want to know, if it is even possible, is how to do it right from sublime, using its console or a plugin (or something), in other words I want to know if it is possible to compile my .c and run it with only e few clicks right on sublime... (for now I am just building console applications)

我读到这里的一些帖子关于这个话题,但这些都不帮我解决这个问题。

I've read some posts here about this topic but none of those helped me to solve this.

推荐答案

一个基本的C编译文件可能看起来像这样:

A basic C build file could look like this:

{   
"cmd" : ["/path/to/gcc", "$file_name", "-o", "${file_base_name}", "-lgsl", "-lgslcblas", "-lm" , "-Wall"],
"selector" : "source.c",
"shell":false,
"working_dir" : "$file_path",

"variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "/path/to/gcc '${file}' -Wall -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}

要编译刚才你preSS <大骨节病>命令 + <大骨节病>乙

To just compile you press command + b.

要编译然后运行你preSS <大骨节病>命令 + <大骨节病>移动 + <大骨节病>乙

To compile then run you would press command + shift +b

您需要做的唯一的事情就是把路径的gcc和inlcude您使用的库(我留下了一些东西,GSL这个例子)。在 $ _变量是崇高的构建系统变量,不应该被改变。有关这些变量的详细信息,请看这里

The only thing you need to do is put the path to your gcc and inlcude the libraries you use (I left some GSL stuff for this example). The $_variables are sublime build system variables and should not be changed. For more info on those variables, look here.

您可以在这里把实际的构建系统文件:

You can put the actual build system file here:

~/Library/Application Support/Sublime Text 2/Packages/User/C.sublime-build

这篇关于如何运行和崇高文本2编译.C [MAC OS X]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆