Eclipse Git project no indexer - eclipse-cdt

I imported a git project into Eclipse Luna. I want to build indexer on the project. However, when I right click there is no Build Indexer option. In addition, under "Properties" I don't see "C/C++ Build" or "C/C++ General" options.

Eclipse looks for the project natures to determine the project type. As Tyler said, maybe they were not imported correctly or never existed.
Right click on project
New ↦ Other ↦ Convert to a C/C++ Project (Adds C/C++ Nature)
Select your setting in the dialog.
Maybe you still need to add the builders either via the project properties and then Builders (dunno how exactly) or just replace/add the <buildSpec></buildSpec> in the .project file in the root directory of your projects with
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>

Related

Problems generating Eclipse CDT project from CMake

If I create a C++ project with Eclipse (Simple Hello World - Project), in the Project Explorer if I do right click -> Properties, I can see a section C/C++ Build in which I can choose, under the Combobox Configuration, Release, Debug, etc..
But, If I create an Eclipse project with CMake using:
cmake -DCMAKE_TOOLCHAIN_FILE=../arm.cmake -DPROJECT=example_01 -DVERSION=1.0.0.0 -G"Eclipse CDT4 - Unix Makefiles" ..
(ignore the params before -G "Eclipse...", I need them to compile), when I import it doing File -> Import -> Existing Project into Workspace, if I do right click as described above, the section C/C++ Build is missing.
Is there a way to make it visible?
Is there a way to add other options in that configuration combobox from the CMake (like FLAGS, or particular commands)?

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:
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?
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:
Create a new project of the same type
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.
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.

Readme file to C++ project

I have a C++ project in Visual Studio. I want to add a readme file to it and that it will be copied to the build folder with exe. Is there any built-in feature in Visual Studio 2010 and 2013?
At project properties (Project menu --> [Project name] properties... menu or ALT+F7) you can find the Post-Build Event tab (Configuration properties --> Build events --> Post-Build Event). Here you can write your macro which copies the readme file to the build folder. You can use the build-in macros to use special folder (i.e. build folder):
https://msdn.microsoft.com/en-us/library/c02as0cs.aspx
A possible solution: copy $(ProjectDir)\ReadMe.txt $(TargetDir)
The easyest way to do this, is right-clicking the file in the solution explorer, choose properties, and there set the "Copy to output directory" option.
Update
As Tanya pointed out this option is only visible in C# projects, but not in C++. The option exists though, only not exposed to the UI. See the answers to this question:
Automatic copy files to output during application building

How to specify which .cpp files to compile based on the current build configuration?

I have multiple build configurations in my project, and I'd like to swap some .CPP files based on the currently selected configuration. How can I do that in Visual Studio 2013?
In the GUI, see properties of a cpp file and set "Excluded From Build" to yes for the configurations where it's excluded.
In the project file would look like:
<ClCompile Include="my_platform_specific_file.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
true
</ExcludedFromBuild>
</ClCompile>
In the IDE.
Select the configuration you want to alter (either from Build > Configuration Manager or the drop down in the toolbar. From the solution explorer, on the file you wish to; right click > Properties > Excluded from Build > Select Yes or No.
In the project file itself, locate the file being excluded
<ClCompile Include="xyz.cpp">
Add the following element;
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MyConfiguration|Win32'">true</ExcludedFromBuild>
Where MyConfiguration is the configuration you wish to exclude the file from.
This might be a good reason to start looking into more generic project managers.
I can recommend you looking into CMake , which is very powerful and can generate VisualStudio projects. The learning curve might be a high (for someone who is used to Visual Studio automation) but the gains are very high.
Some links:
Linking different libraries for Debug and Release builds in Cmake on windows?
http://cmaketools.codeplex.com/ - support for CMake files editing
http://www.youtube.com/watch?v=w9sKd8f0kFo - video displaying cmake integration into VisualStudoi
http://www.cmake.org/Wiki/CMake - random help
The project site is: http://www.cmake.org

Crossed folders in eclipse luna

I've just installed Eclipse Luna and in my project explorer there are appearing some folders crossed out, and I don't know how to remove it and even what it means.
Looks like the Engine and Gameplay folders are also being duplicated. What is going on?
Thanks
I had a similar (the same?) issue after creating a new folder in an existing project. Having found this (incredibly slowly-loading) documentation page, I figured out the gray diagonal line in CDT can actually also mean "excluded from build".
This was readily countered by right-clicking on the folder in the project explorer, choosing
Resource Configurations -> Exclude from Build...
and then deselecting all configurations.
What I did was go to:
Project properties ->C/C++ General ->Paths and Symbols
There I added the folder to the include directories and at the Source Location Tab I clicked on:
Edit filter -> Remove
I think it has to do with how you added the folder to the project (through eclipse, as a source folder or externally)