Search code examples
cbuildcmdcygwinsublimetext2

Error compiling simple C program using Cygwin, cmd and Sublime Text 2


I installed Cygwin in Windows 7. Then I set the environment variable to path, "C:\cygwin\bin", but when i try to build a simple "helloworld.c" file, it displays the following:

[Error 2] The system cannot find the file specified
[cmd:  [u'g++', u'C:\\programs\\helloworld.c', u'-o', u'C:\\programs/helloworld']]
[dir:  C:\programs]
[path: C:\cygwin\bin;C:\cygwin\bin;C:\cygwin\bin;C:\TC\BIN]
[Finished]

and the code i wrote is as follows:

#include <stdio.h>

main()
{
    printf("Hello, world\n");
}

How can it be fixed?


Solution

  • Install all the devel packages because you will need some of them in the near future.

    To this end use setup-x86.exe (or setup-x86_64.exe on 64bits system) because it's the way of installing packages through Cygwin. If you don't have that executable, download it again (it's the one used to install Cygwin).

    Remember using the correct format because in the cmd line at the end you wrote /helloworld instead of \helloword.