| C++11 won't compile on Eclipse Mars [message #1719060] |
Mon, 04 January 2016 14:16  |
Eclipse User |
|
|
|
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 12:06   |
Eclipse User |
|
|
|
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 #1726356 is a reply to message #1719250] |
Fri, 11 March 2016 13:54   |
Eclipse User |
|
|
|
===== 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 15:52] by Moderator
|
|
|
| Re: C++11 won't compile on Eclipse Mars [message #1726388 is a reply to message #1726356] |
Sat, 12 March 2016 03:30  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.04193 seconds