Search code examples
c++eclipsec++11eclipse-cdttoolchain

Eclipse CDT Oxygen: Compiler issue


I'm running Ubuntu 16.04 and just opened my freshly installed Eclipse CDT Oxygen for the first time.

I imported an existing C++ project that builds fine using a CMake file that sets add_definitions(-std=c++11).

I used CMake with the command cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ../src/ to generate Eclipse project files and then used those to import the project into Eclipse.

Now I'm looking at a source file in my newly imported project inside Eclipse and see a ton of issues. It's all types that cannot be resolved, for example std::default_random_engine.

My guess is that Eclipse doesn't have the right toolchain configured.

I have a few questions:

  1. How can I see the toolchain for my project and how can I change it? I looked up this help article, but the sections in the project properties menu I see are not the same as in the help article. The project properties menu I see does not have a "C/C++ Build" section. How can that be?

  2. The CMake file that I used to generate the Eclipse project files specifies that C++11 is supposed to be used, so why isn't this the case then?

Here is what my project properties menu looks like:

enter image description here

This is what my .project file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>particle_filter</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
            <triggers>clean,full,incremental,</triggers>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
            <triggers>full,incremental,</triggers>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.cdt.core.cnature</nature>
        <nature>org.eclipse.cdt.core.ccnature</nature>
        <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
        <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
    </natures>
</projectDescription>

Thanks a lot!


Solution

  • The missing C/C++ Build section can be caused by a broken .project, .cproject or .settings/language.settings.xml file:

    1. Create a new project of the same type
    2. In the Navigator view compare the .project, the .cproject and the .settings/language.settings.xml files with the corresponding files of the new project to find the problem (make sure to use same IDs in .cproject and in .settings/language.settings.xml, but different IDs than in other projects)