Sublime Forum

C++ problem

#1

Hi, I would like to ask you for help because I’ve read a dozen of similiar topics about c++ building problem and still can’t figure it out. I am using Windows 7 x64 and have already installed, sublime text 2, MinGW, also set PATH for minGW in system variables, but it still does not work. As I am pretty newbie, I’m probably gonna pulling my hair out because every time I try to compile the simple “Hello World” program, get this : [Decode error - output not utf-8][cmd: [u'g++', u'C:\\Users\\Kompik\\Desktop\\skuska.cpp', u'-o', u'C:\\Users\\Kompik\\Desktop/skuska']] [dir: C:\Users\Kompik\Desktop] [path: C:\Program Files\Java\jdk1.7.0_05\bin; C:\MinGW\bin] [Finished]
I am so clueless about this things, so please be patient.

Thanks. Appreciate it.

Creck

0 Likes

#2

In the console it says that there is a decoding error on your file:

  • Open your file (skuska.cpp it seems), click on File->Save with encoding->UTF-8

It should bring you to the next step.

0 Likes

#3

thanks for reply thekyz, but still got the same error :confused:
however, here is the code which I am trying to run, hope it’s written well…

[code]#include

using namespace std;

int main(void){
cout << “Hello World” << endl;
system(“pause”);

return 0;

}[/code]

0 Likes

#4

This is far-fetched but I got a similar problem because mingw would use localized versions of the error & somehow the parser would fail on accentuated characters.
Your original code displays an error when compiling because, well, “system” doest not exist in your scope:

C:\dev\tests\main.cpp: In function 'int main()': C:\dev\tests\main.cpp:7:18: error: 'system' was not declared in this scope [Finished in 0.2s with exit code 1]

Try compiling this instead:

#include <iostream>

using namespace std;

int main(void){
   cout << "Hello World" << endl;
   return 0;
}

Edit: If this works try adding/editing the environment variable LC_ALL to force english as a language for the compiler:
LC_ALL = en_US.UTF-8

0 Likes

#5

[quote=“thekyz”]In the console it says that there is a decoding error on your file:

  • Open your file (skuska.cpp it seems), click on File->Save with encoding->UTF-8

It should bring you to the next step.[/quote]

It worked for me!
Thanks you so much!

0 Likes

#6

when ever i ran same hello world code i am getting this error… I am so pissed at this

c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x21): undefined reference to std::cout' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x26): undefined reference tostd::basic_ostream<char, std::char_traits >& std::operator<< <std::char_traits >(std::basic_ostream<char, std::char_traits >&, char const*)’
c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x2d): undefined reference to std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x34): undefined reference tostd::ostream::operator<<(std::ostream& (*)(std::ostream&))’
c:/mingw/bin/…/lib/gcc/mingw32/9.2.0/…/…/…/…/mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x54): undefined reference to std::ios_base::Init::~Init()' c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\aaravan\AppData\Local\Temp\ccBhcSdf.o:first.cpp:(.text+0x75): undefined reference tostd::ios_base::Init::Init()’
collect2.exe: error: ld returned 1 exit status
[Finished in 1.1s with exit code 1]
[cmd: gcc first.cpp -o first && first]
[dir: C:\Users\aaravan\Desktop\C++]
[path: C:\MinGW\bin;C:\Users\aaravan\AppData\Local\Programs\Python\Python37-32\Scripts;C:\Users\aaravan\AppData\Local\Programs\Python\Python37-32]

0 Likes

#7

@aryan_sethi you are compiling with GCC. You must instead compile with G++.

0 Likes