简体   繁体   中英

C++: Sublime Text 2 and MinGW

I need some help configuring Sublime Text 2 with MinGW. All I did was add MinGW to my path variable. I've been having some issues however. for example, this code won't even pause to ask the user for input and immediately puts cin into a failed state.

    int input = 0;
    cin >> input;

It is not a problem with my code either, because I tested it with eclipse and it works fine. What else do I need to get Sublime Text 2 to work with MinGW?

Also, if it would be easier, I'm open to a new compiler.

Sublime Text is an advanced text editor, not an IDE. As requested, here are some instructions for compiling and running a program written with Sublime Text.

Launch a command prompt (press windows-key+R, type cmd , and press enter) and verify that the MinGW bin folder is in your path with g++ --version . If a version is returned, navigate to the location of your C++ source files with the cd command. For example, cd "C:\\Users\\abaratham\\Dev\\test" . Then compile the source files with g++ -o myprogram.exe main.cpp othersource.cpp ... .

If the build is successful, you should see a new myprogram.exe file in the project folder. If it's a command line program, you can run it in the same console with myprogram .

As you begin to develop software with many C++ source files, you might find it useful to use a high level build system such as CMake or SCons. Whichever you chose, you'll be able to generate makefiles and compile your project with mingw32-make .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM