1

I have scoured google for a solution to fix this (including several posts here on c++ 11 features not working) and I can't find a solution. I have grown attached to netbeans in past year, using it for all my computer science courses. But it is slightly bothersome that some features of C++ are limited in my IDE, especially when they are features my professor is using to teach C++. When I use stoi() in any way I get an "Unable to resolve identifier" error. Is there a hot fix of sorts to get netbeans to acquire these features? I've worked around it for my first programming assignment, but since I'm just now learning C++ I'd like to follow my professor's lead at the moment without doing anything extraneous.

I have tried the accepted solution here: How to use C++11 std::stoi with gcc?, and here: Netbeans C/C++ 7.2 -std=C++11 not recognized by gcc v4.6 or lower and I still get errors. And just as a disclaimer, to my knowledge I am using the listed includes involved here. So if anyone has a solution I'd appreciate it quite much.

  "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/cs_240_hw01.exe
make[2]: Entering directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++ -std=c++0x   -c -g -std=c++11 -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
main.cpp: In function 'int main(int, char**)':
main.cpp:24:26: error: 'stoi' was not declared in this scope
     int myint = stoi(test);
                          ^
nbproject/Makefile-Debug.mk:84: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_4.x-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
nbproject/Makefile-Debug.mk:62: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Zachary/Documents/NetBeansProjects/CS_240_HW01'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2


EDIT: Added Build output
Community
  • 1
  • 1
LumberSzquatch
  • 1,054
  • 3
  • 23
  • 46
  • Are you calling it `std::stoi`, not just `stoi`? (Or bringing it into scope with `using namespace std;`, if you haven't yet learnt why that's a [bad idea](http://stackoverflow.com/questions/1452721)?) Are you including ``? Which version of GCC are you using, and how exactly did you try to enable C++11 support? – Mike Seymour Jan 26 '15 at 19:09
  • Yes. I'm using namespace std and I have also tried the other way as well. And yes, I'm using the proper includes. As for your other two questions, I actually don't know what version, and I assumed I downloaded all current versions. So maybe there is a chance I don't have it. How would I know? And if I didn't have either, how would I obtain them? – LumberSzquatch Jan 26 '15 at 19:20
  • `gcc -v` will tell you the version. Hopefully it's 4.8 or 4.9, with good C++11 support that you can enable by specifying `-std=c++11` as a compiler argument (I'm afraid I've no idea how to tell netbeans to do that). If it's earlier than that, then `-std=c++0x` might give you some degree of C++11, but it will be a bit sketchy. – Mike Seymour Jan 26 '15 at 19:25
  • Netbeans build output window should contain exact command line compiler is run with. Add it to your post. C++ standard version used is specified in Project Properties window: `Build - C++ Compiler - C++ Standard`. Also there is `Additional Options` field to specify custom command line options if nothing else suits. – dewaffled Jan 26 '15 at 19:52
  • @frymode, I'm not familiar with what you are speaking of, what do you mean the output window should show the exact command line compiler is run with? You mean all that junk it spits at me before it compiles? And are you saying I would have to add what I need to each project and every project in the additional options? Sorry, I'm not very familiar with alot of the options within netbeans, as I have never had to do anything extra when I was coding in java besides update to 8.0 for JavaFX, so excuse my ignorance if you will. – LumberSzquatch Jan 26 '15 at 20:34
  • @MikeSeymour, and where does the `gcc -v` reside? How do I view what setting it is? – LumberSzquatch Jan 26 '15 at 20:36
  • So I changed the `C++ Standard` from the default to `C++11`, did nothing, and also added `-std=c++0x` to the `Additional Options` and it was still fruitless. – LumberSzquatch Jan 26 '15 at 20:42
  • [Here](http://i.imgur.com/hjBwT2b.png) is screenshot of simple application build output window. I highlighted line where gcc compiler is executed. We can see all the options it receives from the ide there. See how your gcc command line looks like for file that failed to compile and post it here if you still have no clue what is wrong. – dewaffled Jan 26 '15 at 20:48
  • @frymode I added my build output as an edit, because I don't know how to screenshot. I feel like mine looks slightly different, but I don't know if that's because I have Cygwin and yours (appears to be) MiniGW – LumberSzquatch Jan 26 '15 at 20:54
  • In build log it clearly says `BUILD SUCCESSFUL`. The application binary should be located at `dist/Debug/Cygwin_4.x-Windows/cs_240_hw0`. So at least your initial issue seems to be solved :) – dewaffled Jan 26 '15 at 20:57
  • See [the reference](http://en.cppreference.com/w/cpp/string/basic_string/stol) and usage example there - you need to include `` header and use fully qualified name `std::stoi` or add `using namespace std;` or `using std::stoi;` before main to make `stoi` visible. – dewaffled Jan 26 '15 at 21:05
  • I have and am using namespace... – LumberSzquatch Jan 26 '15 at 21:08

0 Answers0