简体   繁体   中英

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:

在此处输入图片说明

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!

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)

I think CMake's CDT project generator is fairly out of date and doesn't configure the generated project properly for C++11 support.

I recommend the following approach for configuring C++11 support:

  • Go to Project Properties | C/C++ General | Preprocessor Include Paths Project Properties | C/C++ General | Preprocessor Include Paths Project Properties | C/C++ General | Preprocessor Include Paths .
  • In the Providers tab, select CDT GCC Built-in Compiler Settings .
  • (If necessary, uncheck "Use global provider shared between projects".)
  • Add -std=c++11 to the "Command to get compiler specs".
  • Apply and rebuild the project's index.

After doing this, C++11 symbols should be resolved properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM