How to deal with Eclipse CDT+Cygwin?

36,593

Solution 1

You have to setup a Cygwin toolchain, first of all install Cygwin with the following packages :

binutils
gcc
gcc-core
gcc-g++
gcc-mingw-core
gcc-mingw-g++
make

Add %cygwin%\bin to your PATH environment variable, then open Eclipse and Cygwin toolchain will be shown when you open a new c/cpp project wizard.

Solution 2

Did you try this Eclipse CDT and Cygwin tutorial for C++?

Solution 3

Have you checcked which Binary parser are you using?

Right click on your project, Properties, C/C++ Build, Settings, Binary Parsers tab, select PE Windows Parser if you are using Windows OS or Elf Parser for Linux OS.

Solution 4

I had similar error and what worked for me is below: In the settings: 'Project|Properties|C/C++ General|Indexer', I unchecked 'Allow heuristic resolutions of includes' and saved the settings. After rebuilding, all my errors like ''std' is ambiguous ...' disappeared.

Solution 5

Giving all basic steps to write hello world program with eclipse + CDT + cygwin-gcc.

You must have missed some steps from 3 to 7.

  1. Install cygwin with packages binutils,gcc-core, gcc-g++, gdb and make. I earlier did not insalled any packages. So I installed the packages after installing cygwin. You can install them by rerunning cygwin's setup exe (Point 3 in this answer) or by using apt-cyg as described in this answer:
  2. Install CDT plugin in eclipse or install CDT eclipse.
  3. Set windows path environment variable to include cygwin bin (C:\Program Files\cygwin\setup\bin) and lib (C:\Program Files\cygwin\setup\lib) directory paths. Set windows classpath environment variable to include cygwin lib directory path.
  4. Run commands gcc,g++,gdb and make in windows command prompt to check if the installed cygwin packages are reachable and are not giving command not found error. For gcc,g++ and make, it should give input or target file not found error. For gdb, it should start gdb prompt, which you can escape by typing Quit in gdb prompt.
  5. Start eclipse and do File > New > C/C++ Project
  6. Select C/C++ Managed build: enter image description here
    Click Next>.
  7. Give suitable project name. Select Cygwin GCC in toolchain:
    enter image description here
    It should create new project and include desired header files from cygwin lib directory specified in environment variables:
    enter image description here
  8. Right click on the project created in project explorer > hover on New in context menu > click Source Folder. Give name src to new source folder.
    enter image description here
  9. Right click on source folder and add new C source file HelloWorld.c: enter image description here
  10. Right click on the project and select Build Project. It should create debug files and executable binaries:
    enter image description here
  11. Right click on open c file, Run as > Local C/C++ Application. It should run the executable generated in earlier step.
Share:
36,593
user1377046
Author by

user1377046

Updated on September 15, 2020

Comments

  • user1377046
    user1377046 almost 4 years

    Recently I installed Eclipse Indigo Service Release 2(for JAVA EE) and installed CDT 8 online.Then I installed Cygwin with gcc,g++,gdb,make,binutils,automake,etc at the latest version.I had also made the environment variable PATH correct.

    Making a new C++ project(using Cygwin GCC toolchain) is just fine,but after typing a HelloWorld program,it shows lots of errors and warings.

    When using external builder,in error it shows

    "Cannot run program "make": ?????????¨?".

    When using internal builder,in conclose it shows

    "g++ -IC:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include\c++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\test_cpp.o ..\src\test_cpp.cpp

    Error: Cannot run program "g++": ?????????¨?

    Build error occurred, build is stopped

    In both Windows CMD and Cygwin Terminal,g++ and make both work well.

    What's more,Eclipse can't find the including libraries,so I have to add the path C:\cygwin\lib\gcc\i686-pc-cygwin\4.5.3\include\c++ to the project properties->C/C++ Building->Settings.But after that, in error,it still shows,

    'std' is ambiguous '

    Invalid overload of 'endl'

    Symbol 'cout' could not be resolved

    In project properties->C/C++ Building->Discovery Options,I set the Discovery Profile scope as Configeration-wide and Discovery profile as GCC per file scanner info profile.

  • Amit Ruhela
    Amit Ruhela about 4 years
    Step 7 not clear. The include files/folders are truncated.
  • Mahesha999
    Mahesha999 about 4 years
    Only first screen shot in the step 7 describes the action to be performed in that step. Second screen shot shows effect of performing the action. Cropped part of 2nd image shouldnt be an issue.