Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Getting c++0x working (with a makefile project using mingw-w64 in eclipse Mars)
Getting c++0x working [message #1706552] Thu, 27 August 2015 11:48 Go to next message
Eclipse UserFriend
Hey folks,

I was wondering if anyone else was having issues getting a makefile project to compile with the c++0x flag set.

I can use the flag successfully with g++ from the CLI but I can not get it to work using make with an eclipse generated makefile either from CLI or from within eclipse. So Mingw-w64 is supporting c++11 stuff, just not when you use a makefile.

I've tried all sorts of settings from all over stack overflow and these forums but with no joy at all.

Any help would be much appreciated.

EDIT:
To shed some more light on the issue, the error is:

error: 'unique_ptr' is not a member of 'std'

I am including <memory>, so std::unique_ptr should be there.

The command that the makefile outputs it's using to compile is:


g++ -std=c++0x -O2 -g -Wall -c -fmessage-length=0 -o "src\\Test\\Test.o" "..\\src\\Test\\Test.cpp"


I have followed the advice on other forums for Luna, I have set the dialect and added the experimental variable and combinations thereof, I have also tried using -std=c++11 and tried the __cplusplus flag too.

[Updated on: Thu, 27 August 2015 16:24] by Moderator

Re: Getting c++0x working [message #1706628 is a reply to message #1706552] Fri, 28 August 2015 05:09 Go to previous messageGo to next message
Eclipse UserFriend
I'm assuming the only problem is that CDT is flagging the references to std::unique_ptr for no apparent reason and that compiles are OK. I had a similar problem a while back where the Indexer wouldn't resolve one of the members of std. Never did find out why.

One work around is to declare it locally but surround it with a guard to hide it from the compiler. Maybe:

#ifdef __CDT_PARSER__
namespace std {
class unique_ptr;
}
#endif

The __CDT_PARSER__ macro is defined only when the Indexer is scanning. You may have to declare any needed members of unique_ptr as well.

Another work around might be to define unique_ptr as a macro within Eclipse to something like void* on the Symbols tab in Project Properties --> C/C** General --> Paths and Symbols. This is tricky as whatever you define it to has to be consistent enough not to generate other errors with the Indexer.


[Updated on: Fri, 28 August 2015 05:10] by Moderator

Re: Getting c++0x working [message #1706632 is a reply to message #1706628] Fri, 28 August 2015 05:35 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for that - but, no, it's not actually compiling either.
I've also set the -std=c++0x flag on the discovery tab in preferences and codan still highlights the error after indexing, your solution may fix this but it seems like the workaround should be unnecessary.

if I create a cpp file using some c++11 code and compile it alone using g++ with the -std=c++0x flag then that file compiles fine.
When I use a makefile, generated by eclipse, it does not compile and throws the error about unique_ptr not being a member of std, despite the makefile showing that it too is setting the -std=c++0x flag when executing g++.
Re: Getting c++0x working [message #1706639 is a reply to message #1706632] Fri, 28 August 2015 06:49 Go to previous messageGo to next message
Eclipse UserFriend
Sorry, I missed the "Eclipse generated makefile" part and originally thought you were using a Makefile project. I don't use managed builds myself or let Eclipse generate my make files.

You may be able to find the compiler command line used by Eclipse, though, and edit it. Even when Eclipse generates the make file the build command under C/C++ Build will still be used. There is an option to use a custom build command so you can control how the files are compiled. Perhaps substitute your own build command to get the -std=c++0x flag set during the build. There is also a build log that you could examine. Maybe you can find out exactly how the files are being built and what is going wrong.

It's strange that no one else has mentioned this problem. Sorry I can't be of more help.




[Updated on: Fri, 28 August 2015 06:51] by Moderator

Re: Getting c++0x working [message #1706641 is a reply to message #1706639] Fri, 28 August 2015 07:06 Go to previous messageGo to next message
Eclipse UserFriend
There is a C/C++ Project Properties, Build, Settings, Tool settings tab that may do the trick for you.
It's under C/C++ Build --> Settings
It apparently doesn't appear unless the "Generate Makefiles Automatically" option is selected.

[Updated on: Fri, 28 August 2015 07:11] by Moderator

Re: Getting c++0x working [message #1706672 is a reply to message #1706641] Fri, 28 August 2015 10:39 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the replies.

The makefile is already adding -std=c++0x to the g++ command, at least according to the output, it still doesn't compile though.

Pretty sure that I've already tried the options mentioned, but I'm at work just now so I'll retry again at home and report back.

Again, really appreciate the help. Smile
Re: Getting c++0x working [message #1706688 is a reply to message #1706672] Fri, 28 August 2015 12:40 Go to previous messageGo to next message
Eclipse UserFriend
Ok so here's the settings I have just now, still not working:

Project->Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Compiler->Dialect->Language standard->ISO C++11(-std=c++0x)

Project->Properties->C/C++ General->Preprocessor Include Paths, Macros etc.->Providers->CDT GCC Built-in Compiler Settings MinGW [ Shared ]->Command to get compiler specs:

${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=c++0x

(this is also set in the discovery tab of the global preferences)

I have also had the experimental variable set and tried a __cplusplus flag as well but these are not set at the moment and did not change anything anyway.
Re: Getting c++0x working [message #1706716 is a reply to message #1706688] Sat, 29 August 2015 00:56 Go to previous message
Eclipse UserFriend
This may seem trivial but copy the g++ command from the log and execute it from the command line. Does it work from there? If it doesn't then what is missing? If it does then the question becomes why it doesn't work when Eclipse executes it. I would then look at the differences in the process environment.

You said, "I can use the flag successfully with g++ from the CLI" but was it with an actual build command used by Eclipse or something else?

Here's a typical compile from one of my builds (note: not generated by Eclipse and I've added line breaks):
g++ -c -Wall -c -std=c++11 -g -O0
-I hdr -I /usr/include
-I /usr/include/c++/5.1.1
-I /usr/include/c++/5.1.1/backward
-I /usr/include/c++/5.1.1/x86_64-redhat-linux
-I /usr/lib/gcc/x86_64-redhat-linux/5.1.1/include

-I ~/proj/LOCALLIB/inc -I~/proj/RXLIBS/inc
-I ~/proj/PNL/cxcore/cxcore/include
-I ~/proj/PNL/high/include
-I ~/proj/PNL/c_pgmtk/include
-I ~/proj/PNL/c_pgmtk/src/include
src/NNBR.cpp -o obj/NNBR.o

I found it necessary to add the system includes for my compiles (italics) which may not be what you actually need. I'm using a Fedora distro.
Previous Topic:shortcut for changing debug command line arguments
Next Topic:how to debug with eclipse
Goto Forum:
  


Current Time: Sat Jul 05 10:21:03 EDT 2025

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

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

Back to the top