Sublime Forum

Pop up appears whenever using string in c++ in sublime

#1


this is the error that i get everytime while using string in sublime.
any solution for this .

0 Likes

#2

bits/stdc++.h is not a standard header file of GNU C++ library. So, if you try to compile your code with some compiler other than GCC it might fail; e.g. MSVC do not have this header.

This header file is not part of the C++ standard and is therefore, non-portable, and should be avoided.

Maybe you are experiencing portability issues with your header.

0 Likes

#3

but even with iostream header file same problem happens.

0 Likes

#4

Could you tell me what command you use to build your program?

0 Likes

#5

basically i use ctrl+b to build the program

0 Likes

#6

Okay, have you installed the g++ compiler properly on your computer? By default, Sublime Text invokes g++ on your C++ file when you press Ctrl+B.

0 Likes

#7

is this what u r talking about?

0 Likes

#8

0 Likes

#9

Yes. Try opening your own terminal window in the F:\c++ directory, then invoke
g++ sublime.cpp -o sublime.exe
followed by
.\sublime.exe

If your g++ compiler works, when you invoke .\sublime.exe, your output.txt file should update to the proper values.

0 Likes

#10

If you still get the same error, I think you want to consider reinstalling/updating your compiler, or using a different compiler.

Either way, the problem is not related to Sublime Text.

0 Likes

#11

after doing this step i am getting the same error.

which compiler can i use then?

0 Likes

#12

You can try installing clang. It usually has better performance on Windows, and is independent of Linux emulators like MinGW. After installing clang and adding to PATH, just do the same thing as before, but invoke clang++ instead of g++.

Instead of MinGW, you can use the Linux Subsystem for Windows. I would choose the Ubuntu distro. When it’s installed you can try invoking the following from a windows terminal in F:\c++:

  1. bash -c "sudo apt-get install g++" (this installs g++, could take a while)
  2. bash -c "g++ sublime.cpp -o sublime" (compile)
  3. bash -c "./sublime" (run)

(Note: For this to work you may need to open your sublime.cpp file and press View -> Line Endings -> Unix in Sublime Text, then save the changes).

This compiles and runs a Linux executable, so you won’t be able to run the program without bash -c. If you want to compile a windows executable (.exe), read this.

0 Likes

#13

thanks a lot clang is working for me .
but now only problem is it is working from command line but not with ctrl+b.
ctrl+b gives the same error

0 Likes

#14

and also bits/stdc++.h is not working

it’s saying header file not found.

0 Likes

#15

I’m glad clang works.

Please read this closely and carefully.

Sublime Text lets you create new build systems that are mapped to Ctrl+B.

Running a build system with the field "shell_cmd": "clang++ $file -o $file_base_name.exe && $file_base_name" should build and run your file. To make your build system run on C++ files, use "selector": "source.c++".

0 Likes

#16

If you really need it, you can probably find bits/stdc++.h somewhere on the internet. Download the file and put it in your F:\c++ directory, then you can just #include "stdc++.h".

Edit: found it.

0 Likes

#17

Sry i did not get about Ctrl+b
but stdc++ is working fine.

0 Likes

#18

Did you read the link? If you read it, maybe you can understand.

0 Likes

#19

ohh there was some typing mistake by me due to which it was not working

but now its working fine
now not even clang even gcc is working

thanks a lot.

1 Like

#20

anyone who faces this problem can refer this and add this code.

{
“cmd”: [“gcc”, “${file}”, “-o”, “${file_base_name}.exe”],
“file_regex”: “^(…[^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“working_dir”: “${file_path}”,
“selector”: “source.c, source.c++”,
“shell”: true,

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

}

if u r using clang compiler then write clang++ instead of gcc in first line

0 Likes