deer's blog

By deer, history, 9 years ago, In English

Guys , i like writing code in sublime text editor and later use ideone to compile and run it . It obviously takes a lot of my time . I was thinking if anyone can help me in configuring ST2 , so that i can compile and run my programs from ST2 itself . I use windows 8.1 .

  • Vote: I like it
  • +14
  • Vote: I do not like it

| Write comment?
»
9 years ago, # |
  Vote: I like it -27 Vote: I do not like it

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Dude , are you seriously like this , or you are just faking ? Either way , it is not cool at all .

»
9 years ago, # |
Rev. 2   Vote: I like it +5 Vote: I do not like it

1> Download MinGW64 . 2> Go to Tools -> Build system -> New build system . 3> Paste this code

{ "cmd": ["g++.exe","-std=c++11", "-o", "$file_base_name", "$file"],

"variants": [

    {   
        "cmd": ["start", "cmd", "/k", "$file_base_name"],
        "shell": true,
        "name": "Run"
    }
]

} and save the build . 4>Select this build system now . Save your programs inside Bin folder in MinGW64 .

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I am getting this error message : [Error 5] Access is denied [cmd: [u'C:\MinGW\include\c++', u'C:\MinGW\bin\hello.cpp', u'-o', u'C:\MinGW\bin/hello']] [dir: C:\MinGW\bin] [path: C:\MinGW\bin;C:\MinGW\libexec\gcc\x86_64-pc-mingw32\4.8.2;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\ActiveState Komodo Edit 8\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\C:\MinGW\bin;] [Finished]

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      Try this :-

      Go to System Properties -> Advanced -> Environment variables .

      Make a new User variable "MinGW64" with the path to MinGW64 folder as value .

      Screenshot

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    thanks it really helps me!

  • »
    »
    8 years ago, # ^ |
    Rev. 4   Vote: I like it 0 Vote: I do not like it

    Doing this pops up a new window. I modified the C++ Single File, to add c++11 support. Here's the modified code.

    { "shell_cmd": "g++ "-std=c++11" "{file}" - o"{file_path}/{filebasename}"",  "fileregex": "(..[: ] * ): ([0 - 9] + ): ?([0 - 9] + )?: ?(. * )", "working_dir": "{filepath}",  "selector": "source.c, source.c +  + ",  "variants":  [ { "name": "Run",  "shellcmd": "g +  + " - std = c +  + 11""{file}" -o "{filepath} / {file_base_name}" && "{filepath} / {file_base_name}"" } ] }

    But, this somehow increases the compile time.

»
9 years ago, # |
Rev. 9   Vote: I like it +1 Vote: I do not like it

If you didn't install mingw already:

Add installation folder to your PATH.

If you enter g++ in command prompt, you should get something like this:

g++: fatal error: no input files
compilation terminated.

Now, Install Sublime REPL.

Then, add below snippet to your Key Bindings — User file. (MenuPreferencesKey Bindings - User)

{
    "keys": ["ctrl+b"],
    "command": "repl_open",
    "args": {
        "type": "subprocess",
        "encoding": "utf8",
        "cmd": ["cmd", "/c", "g++ $file_basename && a.exe && del a.exe"],
        "cwd": "$file_path",
        "syntax": "Packages/C++/C++.tmLanguage",
        "external_id": "c++"
    },
    "context": [
        {"key": "selector", "operand":  "source.c++, source.c"}
    ]
}

Now, just use ctrl+b to run your file.