How to compile C file using Sublime Text on Windows 8.1 64 bit?

Asked

Viewed 12,372 times

6

I installed the Sublime Text in Windows 8.1 64 bit.

How to compile a *.c file through Sublime on Windows?

Is it necessary to install a compiler and/or another program to alert code errors and create the executable file so I can test the program? If yes, what are the most recommended programs [light; practical; stable]?

  • Yes, you will need a C compiler, but I’ll let others recommend one, since I hardly use C or Windows.

  • Yes, in Linux I build on the terminal with Clang, already in Windows I imagined that I needed to install more...

  • Could people who voted against this question explain why it is bad? In my opinion it follows the pattern of the site.

  • I did not understand either Renan... I admit that I did not try much before asking, but soon after I even found the solution and answered below

1 answer

6

Solved!!

I followed these steps contained in this link: http://www.ishaanrawat.com/building-running-c-in-sublime-text-windows/

1: Download the latest version of Mingw

2: Install it preferably on C:/Mingw. I installed the packages mingw32-base and the mingw32-gcc-g++ (I’m not sure if it’s essential to install these two packages)

3: Locate the bin folder path (C:/Mingw/bin)

4: Windows + F -> Settings -> type system environment -> Edit system environment variables or Right click on My Computer -> Properties -> System -> Advanced -> Environment variables

5: In the user variables, click on New. In the name Mingw, already in value put the bin folder path (third step), ex.: C: Mingw bin. Give a Ok, then OK again.

6: Open Sublime Text. Go to Tools -> Build System -> C++

7: Ctrl + B to compile and Ctrl+Shift+B to execute

OBS.: save all files in bin folder without putting them in a folder. The file path must be in this format: C:/Mingw/bin/File.cpp

It worked! D

  • The problem with using Mingw is that it is not necessarily a compiler for Windows. It allows you to create PE executables for Windows, but only as you use only native C functions or a few libraries that have been brought from Linux. You can not use, for example, sockets, which would be fundamental to have since almost everything developed today is oriented to the Web. A more suitable compiler to develop C applications for Windows would be Visual Studio, which has its free version available here.

  • 3

    Hello @webgykl, don’t forget to put a piece of content here (or translate it whole here). It may be that the page goes offline and the answer loses its validity. Also, the solution is in English, so it turns out to be of little help to future users who are not fluent in English.

  • 2

    @Havenard, Why I could not use the Windows sockets api with Mingw?

  • Because there is.

  • 2

    @Guilhermebernal can use the socket API. Windows has a layer that allows you to use the features defined by the POSIX standard. See more: http://technet.microsoft.com/en-us/library/bb463220.aspx Most of the things you do with Visual Studio, you do with Mingw. Using Mingw on Windows for almost 10 years and I only needed Visual Studio when I had to link to some C++ libraries that did not have Mingw versions.

Browser other questions tagged

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