Compile C in Sublime Text

Asked

Viewed 22,761 times

6

I’m using Windows, and need to know how to compile programs written in C in this editor. No ubuntu is easier, but in Windows 8.1 I don’t know how to do it. I’m using Sublime Text 2, because he’s my favorite editor.

  • Normally in windows it is necessary to download a C compiler, some Ides like the devc++, codeblocks already install one, the mingw is another option

  • Look for the CodeBlocks. When I needed to do a work on C in my Windows 8 it served me very well. Both in the editor and in the compiler.

  • Microsoft provides a free version of Visual Studio (you can still use your built-in editor in the microsoft IDE, but that’s some work) https://www.visualstudio.com/en-us/products/vs-2015-product-editions.aspx

  • 2

    Editors do not compile programs.

  • @pmg who compiles is the compiler, but the editor commands it to compile, which is almost the same ;-)

  • Thanks for the help. I’m trying !

  • Managed to solve your problem? In case you still don’t tell us what happened we can help.

  • not yet. I gave up and now I’m using code Blocks :(

  • 1

    I don’t really like the codeblocks, I prefer the Sublime. Did you even try to do what I suggested? I did it here and it worked. Anything say where you got it wrong.

  • Dude, it’s really simple to compile C in sublime text 2. see this video I made myself. https://www.youtube.com/watch?v=bACxGtkzpX0

  • or if you like, look up the name on youtube: "how to set up Sublime Text with C/C compiler++"

Show 6 more comments

3 answers

12


Download the Mingw (GCC ported to Windows) on that website, install it and add the system variables.

Click on Tools > Build System > New Build System, in the window that opens put the code below:

{
    "cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "${file_base_name}.exe"],
    "selector" : "source.c",
    "shell" : true,
    "working_dir" : "$file_path"
}

Save with the name C.sublime-build.

Switch Buildsytem to C: Tools > Buildsystem > C.

Write a code in C and Compile by pressing Ctrl+b or on the menu Tools > Build.

Upshot:

inserir a descrição da imagem aqui

Source: How do I Compile and run a C program in Sublime Text 2?

  • 1

    Set up Javac (and java) and csc (c#) for quick testing, thanks :)

0

The sublime textbox is just a text editor with advanced functionality what it does is just give an Highlight in keywords, complete certain terms etc.

An IDE primarily for statics typing languages is composed of two elements the advanced text manipulation features and the compiler, who is responsible for analyzing the source code, checking for errors and ultimately generating the artifacts.

As in Linux usually already comes some C compiler this is no problem, in windows it is necessary to install (gcc or mingw) one, some Ides that already do this are:

Codeblocks

Devc++

0

If you are with the Mingw installed is just press Ctrl + B.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.