Sublime Forum

[ST2/Windows] Can't build .cpp files

#1

Hi there. I’m new to Sublime Text 2. I want to edit and compile some C++ files, but it fails.
When I opening .cpp file and press “Build” (or Ctrl+B), there are message “Building” appearing for 3-5 seconds. But nothing else happens. Same thing with “Run” command.
Currently my Build System is

[code]{
“cmd”: “C:\MinGW\bin\mingw32-g++.exe”, “-o”, “$file_base_name”, “$file”],

"variants": 

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

}[/code]
But I tried many other configurations and they all failed same way.
May be the reason is I had already installed MinGW in ProgramFiles for DevCpp? Then which of them and how I need to delete?

0 Likes

#2

Okay, I advanced a bit, but still totally disappointed.
Nobody asked about Console Log, but I think it can be interesting. I even didn’t know that Log writes all my Build failures.

Running g++ B:\main.cpp -o B:/main
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 337, in run_
  File ".\exec.py", line 154, in run
  File ".\exec.py", line 45, in __init__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd2 in position 9: ordinal not in range(128)

Or something like this (when I tried to encode one of my files)

Writing file %fill_name% with encoding UTF-8
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 190, in on_post_save
  File ".\sublime_plugin.py", line 154, in run_timed_function
  File ".\sublime_plugin.py", line 189, in <lambda>
  File ".\autogit.py", line 156, in on_post_save
  File ".\autogit.py", line 162, in handleCommit
  File ".\autogit.py", line 75, in adjustPath
  File ".\ntpath.py", line 101, in join
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd2 in position 9: ordinal not in range(128)

And whenever I try to Build or Encode my files, this UnicodeDecodeError happens. I looked forward and found some solutions to modify exec.py file. But hey… I don’t have exec.py file! At least in Sublime Text 2 root directory. I have sublime_plugin.py but I don’t think I can modify something there to fix it. So… my instalation of ST2 failed or what?

0 Likes

#3

So, according to
I added this string in the header of file sublime_plugin.py

import sys reload(sys) sys.setdefaultencoding('utf8')
Now ST encodes files without any errors in Console but it still builds nothing.
I solved this by upgrading to ST3 but I still interested in adequate solution, if it exists.

0 Likes