Custom Makefile With Eclipse CDT - eclipse

I have a C++ project with 3 .hpp files and 1 .cpp file, and a custom Makefile. The code and the Makefile for this project already existed, so I right clicked in the Project Explorer, and did Import->Existing Code as Makefile Project I named my project and pointed the location to the root dir of the project which contains all of my files. And I selected MinGW GCC as my toolchain because that is the compiler that I have. Then I went to Project->Properties->C/C++ Build and unchecked Generate Makefiles automatically
Then I changed my Build directory by choosing File system and navigating to the root directory of my project which contains all of my files. The Build directory is C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges
Then I changed the Build command to make -f C:\Users\Ryan\Desktop\School\CSE\CSE 100\pa1-rbridges\Makefile bst where bst is a target in my Makefile and my Makefile is at that location. When I click the hammer on the toolbar to build my project, nothing happens. When I try to run my project, I get Launch failed: Binary not found.
I just want my project to use my Makefile and build properly.
I have searched Google and stack overflow for hours trying to figure out how to get this to work and have had no luck. Any help is appreciated.

The solution to these sorts of problems usually begins with breaking them down.
First try and build build from the command line. Does the "make -f ..." work from the command line?
It could be an issue with MinGW not working properly.
It sounds like you have done everything correctly as far as eclipse goes. You may find a clue in the eclipse console window.

Too late for giving an answer. But this is for the other people who end up here.
You need to create a new run configuration in Run->Run Configuration... for your project, and then type a name for the output binary file like Debug\name.exe in 'C/C++ Application' box. The name must be the same as the project name.

Related

CMake Eclipse project, make targets not available

I use CMake as a build manager for a C++ project. All my sources are in a src subdirectory, and I created a sibling build directory. Following the directions from https://cmake.org/Wiki/Eclipse_CDT4_Generator, the build commands I use are:
cd build
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ../src
This creates the .project and .cproject files used to import an existing project in Eclipse. In the IDE, everything seems to work perfectly, except that the make target does not work.
When I click on a build target, the CDT build console opens, but nothing occurs. Also when I click on Project / Clean in the Eclipse dropdown menus, nothing occurs. I checked the commands invoked by the targets, and they are of the form /usr/bin/make -j8, which should work.
Can anyone help me get the make target work ?
An automatic update to CDT just occurred and everything works now. So check for updates I guess.
Hope this is followed to create target....
The docs for eclipse says:
Your project name should be different from your executable name and different from your build folder name. Otherwise, Eclipse will NOT pick up your executable as you build them. Since my build folder name is certi_build, a CMakeLists.txt file like below should work (notice the difference in project name and executable name)
PROJECT(AwesomeProject)
ADD_EXECUTABLE(AwesomeProjectMain
main.cpp
util.h
util.cpp
)

Gtkmm in Eclipse makefile project: "could not be resolved"

I am trying to migrate a custom C++ project which uses Gtkmm3.0 to Eclipse (Oxygen) on Ubuntu 16.04. The project has its own Makefile and builds fine from the terminal within Eclipse. What I have not been able to do so far is tell the indexer about Gtkmm, and I get lots of these (which is very annoying):
When I hover over the little red bugs, it says:
Type 'Cairo::RefPtr<Cairo::Context>' could not be resolved.
I have done a lot of Googling on this and found nothing so far because all answers seem to assume the project's build tools are managed by Eclipse (See this or this, for example). In my case I have a makefile project instead of an executable project and hence some options are not available to me. For example, the first links speaks about configuring the builder:
We have to add all this directories. On Eclipse select the Project->Properties menu option. Select C/C++ Build->Settings property page and GNU C++ Compiler->Directories from the Tool Settings tab. Now we have to add all directories. In my case (Makefile project) only two tabs are available there: Binary Parsers and Error Parsers.
How can I tell the Eclipse indexer I am using Gtkmm3.0?
Found the solution that works for me:
Open a terminal and enter:
pkg-config --cflags gtkmm-3.0
You will see a list of includes directories (starting with -I). These are the directories you want to add in Eclipse so that it can locate the Gtkmm symbols in the editor.
In Eclipse, go to:
Project -> Properties -> C++ General -> Paths and Symbols
In the Includes tab, select GNU C++. You need to add here add the include directories found in step 1. There is no automated way to do this, yo must enter them one by one.
One trick that can save you some time is to edit manually the Eclipse project setting XML file and add the include directories directly in the XML file. By the end, you should have something that looks like this:
That did it for me, hope this helps!

Force Eclipse CDT makefile to clean file before compiling

I'm using Eclipse + CDT for a project.
I'm using the "generate Makefiles automatically" option from my build settings.
I have in one file the date and some values that must be actualized every time the project is compiled. But since I don't change every time this file the compiler doesn't refresh it.
Is there any option so I can have a Phony target?
if I could just add some lines to the makefile will work
rm -f *.o target
but this will be removed the next time I update my project.
I found that in the settings >> c/c++ build >> behaviour there is an opportunity to write some clean variables. Could this help? I tried to write the file name but this does not work.
You can give CDT a pre-build command. For me (3.6.2 on Linux):
Project → Properties
C/C++ Build category
Settings sub-category
Build Steps tab
Pre-build steps pane
Enter a command to delete the object file in question (rm f.o, or somesuch)
You can user make clean on Pre-build steps
I added the following to the Pre-build steps and it seems to work great:
del ${CWD}\addtional_dir\file.o

pydev - setting up an existing python27 project complete with dlls and nested source folders in eclipse indigo

I am trying to set up a project in Eclipse Indigo with pydev on windows 7 Pro SP1 x64. The project exists in my drive (downloaded via tortoise svn) and has the following structure :
root\
launcher.pyw
settings.ini
modules\
__init__.py
module1.py
module2.py
...
more_modules\
__init__.py
moduleA.py
moduleB.py
...
compiled\
1.dll
2.dll
...
I have successfully imported the project in eclipse - specifying root/ as the project folder - and when I right click on the launcher.pyw and run the file the program runs alright (it is a gui application). I have 2 (main) issues :
I want to be able to run the project normally (tell eclipse that when I run the project I actually mean run the launcher.pyw) - when I right click on the project > Run as > Python-unit-test is the only option
I have, say, in more_modules\moduleA.py something like from .. import module1 which shows as an error - so how should I set it up correctly ?
Not sure about the dlls folder also - and not sure about the code analysis - aparently I have to open a file to see the errors - but those belong to another question maybe
The project sourceforge page is : http://oblivionworks.svn.sourceforge.net/viewvc/oblivionworks/Programs/Wrye%20Bash/
The root/ is Mopy/
Edit: moved the picture from my comment:
Regarding launching, you can simply open the file and press F9 to run it. After that, if you've set to rerun the last launch in the preferences (see instructions at: http://pydev.org/manual_101_run.html), you can simply press Ctrl+F11 to rerun it.
I took a look at your sf page and noted you didn't commit the .project and .pydevproject files (please do, so that anyone using PyDev can get things configured directly).
Regarding your import error in the code analysis, it'd be nice if you can actually provide the real example (from your description the error is that you have a '.py' in the end of the module that probably shouldn't be there, but it may be just a description... if it runs and code-analysis doesn't get it, please create a project with that use case and attach it in a bug-report in the pydev sf tracker).
As for the code analysis, usually you really have to open a file to see errors, but you can also right-click a folder and choose pydev > code analysis and it'll do a code-analysis for all the files beneath that folder that are a part of your pythonpath.

System.getProperty("user.dir") anomaly in Eclipse

In my current project settings, I have configured Eclipse to place the compiled .class files in the /bin directory.
My puzzle is that, when I run the application via the IDE and get it to print the current working directory (System.out.println(System.getProperty("user.dir")) I expect the console output to be /bin - instead the value printed is the projectRoot folder (without the /bin suffix).
If I were to navigate to the /bin folder directly, and execute my java class, the current working directory is printed as I expect it to be. What I would like is the Eclipse IDE to behave similarly.
Any ideas as to why I am observing this disparity? I have gone through many project build settings, but cannot seem to find anything that would cause this anomaly.
Kind regards,
Dinuk
In Eclipse, the working directory defaults to the project directory.
You can change this in the run properties
(Project->Properties->Run/DebugSettings->Edit->Arguments tab, at the bottom of the page).
Edit: Actually, the easiest way to get to it is Run->Open Run Dialog->Arguments tab.
It's been a while since I used Eclipse.
From an example of Eclipse Setup New Project
alt text http://apps.sourceforge.net/mediawiki/sprite2d/nfs/project/s/sp/sprite2d/a/ae/EclipseNewProjectDebugArguments.jpg