Specifying external Makefile options in Eclipse CDT - c++

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.

Related

QtCreator 4 and CMake parameters

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

How to run .exe immedeatly after build in Eclipse CDT [duplicate]

I'm trying to conveniently have the updated code in effect when I click the run button in Eclipse. At present it will run the last build and I have to manually click build before clicking run to see the changes.
Can someone advise me on how to configure Eclipse to autobuild the current project (if changes has been made) before running the code?
There are multiple settings for auto building. The one you could be missing is the setting under Launching.
Two other settings are here:
And the last setting is the one you likely already know about:
If you want to automatically build your project on save (or before run, if needed), then from tool-bar menu go to
Project -> Properties -> C/C++ Build -> Select Behaviour Tab on the right panel, -> tick the "Build on resource save(Auto build)" , finally hit OK
That is it...

Porting several dependent C++ makefile projects into MSVC

I have several projects which depend on each other. For example, when I install them I do this:
Project1:
/configure & make & make install
Project2:
/configure & make & make install
Such that "Project2" depends on some libraries of "Project1". I want to create an MSVC project for Project2, and start working with it, and changing it (and compiling it inside). How can I do this?
Also, how different is this to be done in linux with Eclips (when you don't have admin permission and can't do 'make install')?
You can create project dependence in Visual Studio.
To assign dependencies to projects
In Solution Explorer, select a project.
On the Project menu, choose Project Dependencies.
The Project Dependencies dialog box opens.
On the Dependencies tab, select a project from the Project drop-down
menu.
In the Depends on field, select the check box of any other project
that must build before this project does.
You can read more about it here
Visual Studio is your usual clickfest, but you can define project dependencies.
Define one project per module, then go to the solution properties tab and, for each project, select the checkboxes that inform the IDE that this project depends on a set of other projects.
The IDE will then sort and build them in the appropriate order.

The program file specified in the launch configuration does not exist

I am facing some problems regarding eclipse for c/c++. I am trying to create a new project, I provide the code, and after running the code I get this error:
The program file specified in the launch configuration does not exist
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
Please notice that I am working with spice toolkit; I set the path for the "include" files and the libraries, but still I can not have a result.
What causes this error and how can I resolve it?
Right click on your project --> Properties
Run/Debug settings
Delete whatever is set as "launch configuration for '........'
Project --> Clean
Project --> Build Project
You can create a run configuration. Go to Run > Run Configurations. Click New button, fill C/C++ Application field, i.e., insert path to your executable. The new configuration will appear in the list which appears when you click to the arrow next to run button.
Of course this assumes your can build without problems, otherwise you won't see an executable to point to.
You can clean the project, build it again and run it as a local C/C++ application. Simplified steps as follows,
Right click on the project
Clean Project
Again Right click on the project
Build Project
Again Right click on the project
Run As ->
Local C/C++ Application
As the error reads:
C:\Users\elisabeth\workspace\mm\Debug\mm.exe not found
First of all you need to check whether there is an executable "mm.exe" in your Debug folder. (Of course, it is not there and that is why the error)
Go to Project > Clean
and you should see some files being deleted from your Debug folder
Go to Project > Build Project
and you should see some new files being generated e.g. mm.d, mm.o, mm. This "mm" is probably the executable you're looking for
Now that you know what your executable is, you should tell eclipse what file to execute instead of mm.exe. Go to Project properties and in run debug settings create a new configuration (or edit an existing configuration, if there is one already). In this configuration, in main tab, in C/C++ Application specify a full path to "mm". Which, in your case is - "C:\Users\elisabeth\workspace\mm\Debug\mm"
A better way to do this in eclipse is:
${project_loc}/"your folder"/"your executable file"
e.g.${project_loc}/Debug/mm
what worked for me is file->refresh
then do the Debug configuration again by choosing the right c/c++ binary again.
Avoid troubles with configuration by going into Project properties > C/C++ build > Refresh Policy and specify your project folder. The configuration option "Search project" will show a correct folder then and you will see whatever you build there - Debug, Release or both. You don't want to specify the folder using Browse option every time you import project or switch configurations.
As this is the first SO discussion that appears for this topic on Google and none of the answers solved the problem my students were having, I would like to mention the solution we eventually found from this answer:
Open project properties (Right click on your project, choose Properties on the menu)
C/C++ Build -> Settings
Click on Binary Parsers tab and check PE Windows Parser
Keep clicking Move Up until it is at the top
This had been set to Elf, even though we were using a freshly downloaded Windows version of Eclipse.
sometime missed closing curly brace can be part of a problem. Make sure prototype your function at the beginning of the file. Then right click your project in the left side bar. click clean project. then click build project and finally run project
I encountered similar issues and their related problems a few days ago. Finally, I found out that, just because I had moved my project folder (workspace folder of Eclipse) to another place so Eclipse could not find what its need as usual.
Solution: I just set the workspace to my new place (Hey Eclipse, my workspace now is here) :
Menu "File" -> "Switch workspace" -> "Other..." -> click "Browse..." button and point to new place then click "Select Folder" button and click "Launch" button.
Nice day.

How to import C makefile project into eclipse or put in under eclipse

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"