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)?
Related
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.
I'd like to (temporarily) migrate a C++ project from Netbeans to Eclipse (in order to use Eclipse's parallel debugger). So far I've created a "Makefile project with Existing Code" project in Eclipse that references the Netbeans project Makefile/directory. However the Netbeans project accepts config options for example
make -f Makefile CONF=GNU_Debug
How can I pass this option to the Makefile in Eclipse?
Eclipse version
Eclipse for Parallel Application Developers -- Mars.2 Release (4.5.2)
You can change the default make call in the projects properties dialog:
My version:
Version: Mars.1 Release (4.5.1)
Note that the -f Makefile should be superfluous.
In addition to πάντα ῥεῖ's answer, which changes settings "globally" for a project, you can define individual make targets in the Make Target view.
Steps:
Choose Window -> Show View -> Other... -> Make -> Make Target (or simpler, press Ctrl+3 then type Make Target and choose the view from the list.)
Right click on the project in the view and choose New...
Enter the make target you want to use, e.g. CONF=GNU_Debug and press OK
Double-click on target to build
Here is a screenshot:
Shortcuts
You can quickly rebuild last selected Make target by pressing F9
Bring up a pop-up to select Make target by pressing Shift+F9
Access the same UI as above by right-clicking on project in Project Explorer and choosing Make Targets -> Build or selecting the same from the Project menu.
I used to open a CMake-based C++ project with QtCreator and pass my custom CMake command line parameters when configuring the project. In the recent versions of QtCreator (QtCreator 4 to be precise), this does not seem to be possible anymore - QtCreator configures the project with its own set of CMake variables and their default values. This is extremely annoying, because the only way to change the values of certain CMake variables is to click on 'Projects' and modify the variables one by one, which is really tedious. I have the configuration parameters for specific machine and setup on that machine in a text file that I could just paste in the configuration dialog of Qtcreator and then run CMake, but this dialog now disappeared. Do you know if there's a way of passing custom CMake values while opening a new project?
I tried to clean the build directory, remove CMakeLists.txt.user in the source tree, run CMake with my parameters and then open the project with QtCreator. Unfortunately, QtCreator ignores the cached values and generates its own ...
"Tools" > "Options" > "Build & Run" > "Your kit" > "CMake configuration"
Add a line and rebuild. You can go the short way Ctrl+5 (Projects mode) > "Manage Kits...", too.
#Manuel's answer is ideal for me when I have toolkit-specific CMake variables without project-specific variables.
When you have project-specific CMake variables, the options I have seen/used with recent QtCreator versions (~4+) are:
From QtCreator
Open the project
go to Projects (on left) and select Build Settings
Under CMake, use the "Add" button to add new settings
"Apply Configuration Changes"
"Build" menu, "Run CMake"
Notes:
if your project updates CMake variables (as most do), you may need to "Apply Configuration Changes" again.
if you have enabled the feature to automatically run CMake, it may fire off in the background, further confusing things. This can create chicken and egg situations - boo!
Outside QtCreator
Go to the build directory
Run CMake with your commands as usual
Open QtCreator
Open the project
Under Projects - Build Settings:
Confirm that the "Build directory:" is as expected
Confirm that your CMake variables appear in the list of variables
Sadly, I find both of these profoundly unsatisfying...
Since QtCreator 4.13 it is possible to set CMake parameters per project (finally):
Project > Build Settings > CMake > Initial CMake parameters
I am looking to add a few libraries to Eclipse CDT (latest version 8.2). However under the project -> properties -> c/c++ build -> settings....There is no tool settings tab where I can configure my include files and the linker like I see with so many other tutorials online. What appears is what is shown below. Is this new for the newest version of the eclipse CDT or did something get configured improperly in the download. Thanks for the help.
Go to Project Properties -> C/C++ Build -> Builder Settings -> (x) Generate Makefiles automatically
then the tool settings tab under Settings will appear
Same Problem here, with KEPLER.
I switched C/C++ Build->Builder Settings->Builder type to External Builder and closed the properties window. When reopening properties the C/C++ Build->Settings->Tool Settings Tab was available.
Edit: If the External Builder switch is disabled, it can help to change the toolchain settings. By switching to e.g. MinGW and back, the switch becomes accessible.
Includes, symbols, libraries, and other references should be under "C/C++ General" | "Paths and Symbols" (I'm using Juno)
My solution was to apply another tool-chain. Under Project->Properties->C/C++ Build -> Tool Chain Editor. I unchecked "Display compatible toolchains only" and selected Cross GCC.
After apply and OK, I could edit the Tool Settings and add include-paths there.
Hope it works for you as well.
Make sure you have a proper tool chain installed in Eclipse.
Open Eclipse/Help/Install New Software ...
Click on the "already installed" link in the bottom right corner.
If your tool chain is not there:
Select All available sites from the Work with combobox.
Expand Programming Languages
Select your tools and install
I have standard source code package under Linux which requires to run
./configure
make
to compile it (and it works ok).
Mostly these files are C/C++
Is it possible to put this project under Eclipse control? I wish to browse definitions etc...
UPDATE 1
I have Eclipse Indigo running on Ubuntu. It contains CDT of course.
When I choose File-Import, I see no matching option under C/C++. Under General I have Existing Projects into Workspace but I get No project are found to import if I point this wizard to my project root.
UPDATE 2
I have installed Eclipse with Ubuntu package manager. Probably this was wrong.
First run the ./configure to generate the Makefile.
After that, if you have CDT installed,just choose the option
"File->New->Makefile Project With Existing Code" and point to the directory where the Makefile is stored.
Create a new project, make sure to uncheck the "Use default location" option while doing so. Add your source tree path in the location field. Now select "Makefile Project" in the project types window.
In "builder settings" (Project>Properties), uncheck the "use default build command" and add:
make -f /<your project location/Makefile
If your makefile is named otherwise, you can change it here.
To run your application, add the application in Run Configurations. See full instructions here.
Don't say import.
Create a new C/C++ project using the New Project Wizard, and specify the "root folder" as a non-default location of the new project.
See the instructions here.
Read "Creating new projects from existing source roots"