Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Run mingw with Eclispe CDT. How to specify which compiler?
Run mingw with Eclispe CDT. How to specify which compiler? [message #1833024] Thu, 01 October 2020 00:14 Go to next message
Anthony Mising name is currently offline Anthony Mising nameFriend
Messages: 5
Registered: October 2015
Junior Member
It is annoying to have to use CDT with every reference to a C++ type like string and vector flagged as an error.

Having spent *many* hours on this, I cannot see any way to tell CDT which compiler to use. I want cdt to use x86_64-w64-mingw32-c++.exe. I even put this on the PATH before starting eclipse. The mingw was installed via and with cygwin.

I do not want eclipse to make, run or debug anything. Just edit. But get the
#include <xxx>
right.

I tried hacking
Project Properties / C/C++ General / Preprocessor Include Paths / GNU C++ CDT User Setting/GNU C++
and
Project Properties / C/C++ General / Paths and Symbols / Includes / C++

But they are only for #include ""s. I tried hacking my code to replace <>s with ""s but the inlcudes include other includes with <>s.

My current solution is to define dummy classes like string under an #ifdef that gets rid of them at make time. vi has become very appealing.


Re: Run mingw with Eclispe CDT. How to specify which compiler? [message #1833067 is a reply to message #1833024] Thu, 01 October 2020 16:15 Go to previous messageGo to next message
Joost Kraaijeveld is currently offline Joost KraaijeveldFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,

Did you install Cygwin/MinGW correct?

What happens if you compile a "Hello world!"-program using a Cygwin terminal? And what if you compile the same program if you use a Windows terminal? What is (in both cases) the command line you used and what is the response of the compiler/linker? What is (in both cases) the output of "gcc --version"?




Cheers,

Joost
Re: Run mingw with Eclispe CDT. How to specify which compiler? [message #1833085 is a reply to message #1833067] Fri, 02 October 2020 01:06 Go to previous messageGo to next message
Anthony Mising name is currently offline Anthony Mising nameFriend
Messages: 5
Registered: October 2015
Junior Member
Always made under cygwin. Makes fine.

x86_64-w64-mingw32-g++ -Wall -Werror -I. -Iinclude -Isrc -fstack-protector -D_FORTIFY_SOURCE=2 -fno-builtin -g -c src/xxx.cpp -o ...

$ which x86_64-w64-mingw32-g++
/usr/bin/x86_64-w64-mingw32-g++

D:\cygwin64\bin;D:\cygwin64\usr\bin appended to PATH before starting eclipse.

I am expecting a setting that that tells CDT how to find the compiler or include<> paths. I could not find one. So I am guessing that it is hard coded into eclipse. What compilers do work? Maybe I need to link something that it would expect, like g++ to x86_64-w64-mingw32-g++?

It would be amazingly bad design to have this hard coded with no override possible though.

I used cygwin to install mingw. I never want eclispe to make anything. No compiles. No debugs. Just get the incudes to work.
Re: Run mingw with Eclispe CDT. How to specify which compiler? [message #1833087 is a reply to message #1833085] Fri, 02 October 2020 05:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Maybe this article will help.
Scroll down to "Console View" to see the dialog.
The article is somewhat out of date
The shown "Discovery" tab is now found with
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Providers tab
https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php

You likely need to change the command used to get compiler builtins.
Typically it is: ${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
with ${COMMAND} being the compiler in the current toolchain (gcc derivative assumed).
You could try changing it to x86_64-w64-mingw32-gcc ${FLAGS} -E -P -v -dD "${INPUTS}"
x86_64-w64-mingw32-g++ might also work.
gcc will call the correct compiler (C or C++) depending on the extent in ${INPUTS}
g++ might not.

You might want to add the correct path to the compiler here (/usr/bin/ ?) so you won't have to rely on the system path.
Note: the path depends on how Eclipse was started (e.g., from a cygwin command prompt vs. system prompt)
You could use the "Allocate console" flag to verify it.

----
You can also add the builtin paths manually to
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab
but you likely will need to set the Contains system headers flag
and maybe the Treat as built-in flag as well
https://help.eclipse.org/2020-06/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_sd_entries.htm&cp%3D10_4_7_0_4_6_0
Scroll down to "Adding and Editing entries"
This is also in the article that I linked but, again, that is out-of-date.
Unfortunately, so is the current documentation in places as the dialogs have been moved and/or modified.
But the topics covered are still valid




[Updated on: Fri, 02 October 2020 05:29]

Report message to a moderator

Re: Run mingw with Eclispe CDT. How to specify which compiler? [message #1833136 is a reply to message #1833087] Sat, 03 October 2020 10:28 Go to previous messageGo to next message
Anthony Mising name is currently offline Anthony Mising nameFriend
Messages: 5
Registered: October 2015
Junior Member
Thanks for that.

I done stuff and it finally goes, but I am not sure why.

One issue is that it is important Re-resolve Includes before Search For Unresolved Includes. Took me a while to see that, so I chased some ghosts.

Outside eclipse I
set COMMAND=x86_64-w64-mingw32-c++
which may relate to the
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

I presume one of "Built In" and "System Headers" means <> instead of "".

I added some paths to Project > Properties > Paths and Symbols > Includes > GNU C++ (No "Built In" option.)

In the Project > Properties > Preprocessor Include Paths I discovered that clicking things in the "Providers" tab makes things appear in the "Entries" tab.
o Entries > CDT Managed Build Setting Entries
The added paths turn up here, but "Supplied by system not editable". They were actually supplied by me above.
o Entries > CDT GCC Built-in Compiler Settings MingGW
Empty. Although later showed a command line.
o Entries > CDT User Setting Entries
I had added paths here, file system path, builtin, system. Then reset defaults and they are gone.

I strongly suspect that the project file states are not fully reflected in the dialogs, that adding things and removing them leaves fossils that make a difference. But I have not investigated.

The UI is thoroughly confusing.
Re: Run mingw with Eclispe CDT. How to specify which compiler? [message #1833139 is a reply to message #1833136] Sat, 03 October 2020 11:23 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You can only edit CDT User Setting Entries the rest are supplied by Eclipse scanners (providers).
CDT GCC Built-in Compiler Settings MingGW come from running the builtins command.
CDT Managed Build Setting Entries get the values set in Paths and Symbols and in the tool settings.

[Updated on: Sun, 04 October 2020 03:40]

Report message to a moderator

Previous Topic:Windows - meson build problem
Next Topic:Integrating Qt and JIVE with Eclipse - opinions wanted
Goto Forum:
  


Current Time: Fri Oct 04 21:41:03 GMT 2024

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

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

Back to the top