Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » C++11 won't compile on Eclipse Mars(I cannot get C++11 code to compile on Eclipse Mars release 4.5.1 with MinGW GCC ver 4.8.1)
C++11 won't compile on Eclipse Mars [message #1719060] Mon, 04 January 2016 19:16 Go to next message
Stephen Dolley is currently offline Stephen DolleyFriend
Messages: 3
Registered: January 2016
Junior Member
I have read every post I can find. I have Eclipse Mars release 4.5.1 and MinGW GCC ver 4.8.1

I have done the following:

Create new workspace.
Created File > New > C++ Project.>Executable>Hello World
Built and Run successfully
added the line
auto i = 6;

The IDE shows

'auto' changes meaning in C++11; please remove it [-
     Wc++0x-compat]


I then went to
project>C/C++ Build>Settings>Tool Settings>GCC C++ Compiler>Dialect>Language standard and selected C++11.

I also went to
project>C/C++ General>Preprocessor Include Path>Providers Select CDT GCC Built-in Compiler Settings and unticked "Use global provider..." box then add std=c++0x

Finally I chose Project>Refresh and Project>Index>Rebuild But still the error on auto.

Is this Wc++0x-compat switch a problem? Where do I find it? What else should I do?
Re: C++11 won't compile on Eclipse Mars [message #1719160 is a reply to message #1719060] Tue, 05 January 2016 17:06 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I get this only when the dialect is left untouched. Post the build log output of a compile. if it doesn't have the -std=c++11 or -std=c++0x flag then you didn't select it in the compiler dialog page.

Here's a small program:
#include <iostream>
using namespace std;
#include <string.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_multifit.h>

int main (void)
{
printf("Starting...\n");
fflush(stdout);
auto x = 7;
int i, j, nr = 5, nc = 3;
gsl_matrix * A = gsl_matrix_calloc (nr, nc);
return 0;
}


And here is the build log with C++11 was selected
Note that the compile command starts g++ -std=c++0x -O0 -g3 -Wall
make all 
Building file: ../src/GSL_TEST.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/GSL_TEST.d" -MT"src/GSL_TEST.o" -o "src/GSL_TEST.o" "../src/GSL_TEST.cpp"
../src/GSL_TEST.cpp: In function 'int main()':
../src/GSL_TEST.cpp:19:6: warning: unused variable 'x' [-Wunused-variable]
 auto x = 7;
      ^
../src/GSL_TEST.cpp:20:5: warning: unused variable 'i' [-Wunused-variable]
 int i, j, nr = 5, nc = 3;
     ^
../src/GSL_TEST.cpp:20:8: warning: unused variable 'j' [-Wunused-variable]
 int i, j, nr = 5, nc = 3;
        ^
../src/GSL_TEST.cpp:21:14: warning: unused variable 'A' [-Wunused-variable]
 gsl_matrix * A = gsl_matrix_calloc (nr, nc);
              ^
Finished building: ../src/GSL_TEST.cpp
 
Building target: GSL_TEST
Invoking: GCC C++ Linker
g++  -o "GSL_TEST"  ./src/GSL_TEST.o   -lgsl -lgslcblas -lm
Finished building target: GSL_TEST
Re: C++11 won't compile on Eclipse Mars [message #1719250 is a reply to message #1719160] Wed, 06 January 2016 15:36 Go to previous messageGo to next message
Stephen Dolley is currently offline Stephen DolleyFriend
Messages: 3
Registered: January 2016
Junior Member
OK. Somehow the dialect selection got set back. I've fixed that and now auto is OK, but unique_ptr gets underlined in red with "Symbol 'unique_ptr' could not be resolved", even though it compiles and runs OK. Here is my program:
#include <iostream>
#include <memory>
using namespace std;

int main() {
	auto i = 6;
	unique_ptr<int> heapInt(new int{7});

	cout << "!!!Hello World!!! Int is " << i << " HeapInt:" << *heapInt << endl;
	return 0;
}

Here is my build log.
Info: Internal Builder is used for build
g++ -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\TestC++11.o" "..\\src\\TestC++11.cpp" 
g++ -o TestC++11.exe "src\\TestC++11.o" 
 

[Updated on: Wed, 06 January 2016 15:50]

Report message to a moderator

Re: C++11 won't compile on Eclipse Mars [message #1726356 is a reply to message #1719250] Fri, 11 March 2016 18:54 Go to previous messageGo to next message
Hristian Temp is currently offline Hristian TempFriend
Messages: 3
Registered: March 2016
Junior Member
===== UPDATE HEADING ======
Solution to the problem "Symbol 'cout' could not be resolved"

Unlike in Java or Python, etc., in C++ one does not select "File/New/C++ project", but "File/New/Project". And then from the newly open window, expand the "C/C++ option" and select "C++ Project".

Personally, I find this totally NOT normal, especially if one uses Eclipse for Python and Java.

Certainly, one has to follow the setup steps listed in Eclipse "C/C++ Development User Guide", "Before you begin" section. I accessed this from the Eclipse Workbench "C/C++ Development" link.

===== UPDATE ======
Hello.

I would very much appreciate if you post the solution, when you find one.

After searching on the Internet for quite a while, I did this:

- I just downloaded Eclipse for C++. I installed MinGW.
- I added this directory to the path.
- I added "-static-libgcc -static-libstdc++" to C++ Build/Settings/MinGW LIkner/Miscellaneous.

And I still get error, "Symbol 'cout' could not be resolved" when I create a new Hello project.

I find so laughable and totally ridiculous that one cannot even run a simple Hello project. I just wanted to see how C++ is and how it runs on Eclipse. And it turned into a total disaster that took my entire evening away while searching on the Internet. This really sucks from the perspective I am looking at it now. A product which cannot even create, build and run a "Hello World" project. The first in my life!!!

[Updated on: Fri, 11 March 2016 20:52]

Report message to a moderator

Re: C++11 won't compile on Eclipse Mars [message #1726388 is a reply to message #1726356] Sat, 12 March 2016 08:30 Go to previous message
Stephen Dolley is currently offline Stephen DolleyFriend
Messages: 3
Registered: January 2016
Junior Member
I have given up trying to get this to work on Windows with MinGW.
I used VirtualBox with a Ubuntu intstallation, and even that was not straight forward, but eventually I got to the bottom of it and now everything works fine.
I have written full step-by step instructions which is in the attached file.
Previous Topic:Symbol 'std' could not be resolved and Symbol 'cout' could not be resolved.
Next Topic:Eclipse with CDT doesn't accept C++11 features
Goto Forum:
  


Current Time: Thu Apr 25 00:27:57 GMT 2024

Powered by FUDForum. Page generated in 0.02996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top