Sublime Forum

G++ command not found

#1

Hi ,
I have installed the sublime text and added Mingw in the path…
Though I can use Codeblocks with no problem , I can’t write c++ code in Sublime Text
Its showing:
/bin/bash: line 1: g++: command not found

If I use c++ Single File :
c:\mingw\include\wctype.h:87:20: fatal error: stddef.h: No such file or directory #include <stddef.h>
^
compilation terminated.

my code is:
`#include
using namespace std;

int main(){

cout << "Hello World!";

}`

0 Likes

#2

How are you building that source? Does the command g++ work in a terminal?

This error message:

c:\mingw\include\wctype.h:87:20: fatal error: stddef.h: No such file or directory #include <stddef.h>

means that your compiler is somehow missing it’s own includes, so either the MinGW installation is borked or is missing some environment variables or something similar. I can’t help you much with that, as I haven’t used MinGW for many years.

Btw.

#include

is missing the file to include, it should be #include <iostream> to use std::cout.

and

int main(){
    cout << "Hello World!";
}

is wrong. You must return an int from main - that’s the int before main:

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

As to what int to return, 0 is the only integer guaranteed to work everywhere and mean “no error”.

0 Likes

#3

sorry , but it doesn’t works

0 Likes

#4

Unfortunately, it doesn’t look like a sublime error, perhaps as @Release-Candidate says “means that your compiler is somehow missing it’s own includes, so either the MinGW installation is borked or is missing some environment variables or something similar.

However, also:

#include <iostream>

int main(){
    std::cout << "Hello World!";
    return 0;
}

I’m fairly sure you don’t need the stddef.h header file at this point, so no need to include it. Try the code I’ve posted.

0 Likes