Reputation: 3905
I have existing C-Code and an existing Makefile, which I want to wrap into an Eclipse C-Project (Using Eclipse 3.4 Ganymede). The Code is organized like this:
Main Directory: /Project/Software
Source and Headerfiles: ../Project/Software/CodeDir1 ../Project/Software/CodeDir2
etc..
So far I have been doing these steps:
Software
--> Now Eclipse integrates all Source files etc. into the ProjectFirst time I do this, everything works fine. I get the output into my console and everything is cool. But then the "Build Icon" (The little hammer) is greyed out and I cant click it anymore. If I now go to the Project Properties -> C/C++ Build it just says "This project is not a CDT Project" and also I get an Error with a "java.lang.NullPointerException".
How can I get a working project?
edit:
To avoid a simple bug I tried the same with the new Version of Eclipse (Kepler). I get the same Error ("No CDT Project") but without the Null Pointer exception.
But I could narrow down the problem a bit: The first time I start the make process it always works. If the build process fails, I can still go to my Build Properties. As soon as I get one complete and error free build run, this issue occurs. Regarding this, it only happens when my make call is done from Eclipse. If I call it from the command line, I can still make one run out from eclipse.
Upvotes: 15
Views: 33926
Reputation: 71
Happened to me when I had included .cproject file in my .gitignore and then cloned to a new PC.
Upvotes: 0
Reputation: 4677
I was able to overcome this by installing/updating corresponding CDT plugins like 'Visual C++ support'.
Upvotes: 0
Reputation: 766
If you are importing an existing CDT project and see “This project is not a CDT project”, it could be that the project was created on an older version of Eclipse, and you need to:
Project Explorer
tab,This will add a new .cproject
file, and you are then ready to go.
Upvotes: 32
Reputation: 3905
The root of the problem is not located in Eclipse, it's in the makefile.
The directory structure of the whole Project is the following:
Project_Dir\Documentation\
Project_Dir\Output\
Project_Dir\Software\
Project_Dir\Tools\
The Source files are all located in the \Software\
directory. So I chose Project_Dir\Software\
as the project folder, which meant that the .project
and .cproject
files are located there.
The makefile itself temporarily writes the outputfiles in the \Software\
folder as well. In the end it copies all files from the Software
dir to Output
(practically a move *.* Project_Dir\Output\
command)
This command was also moving the Eclipse project-files, thus making it hard for eclipse to find them and open the project properties.
Two solutions:
\Project_Dir\
since it's all project related stuff anywayattrib +r +s *.project
and attrib -r -s *.project
after the move command. (Same for .cproject
). This prevents the makefile from moving the filesUpvotes: 0
Reputation: 28415
When creating your new project you need to create it as a makefile
project - it will then use make to build the project but setting build properties up needs to be via your makefile and the make invocation.
This link tells you how to create a makefile project:
To create a project:
Select File > New > Project.
When you create a new project, you are required to specify the project type. This project type will determine the toolchain, data, and tabs that the CDT uses/displays.
Select the type of project to create. For this tutorial, expand the C/C++ folder and select C++ Project. The C++ Project wizard opens. Click here to see an illustration.
By default, the CDT filters the Toolchain and Project types that currently display in those lists are based on the language support for the C++ Project wizard you selected for this tutorial.
In the Project name field, type HelloWorld. Leave the Use Default Location option selected.
Next, you want to select the type of project to create. In the New CDT Project Wizard, you can choose from the following project types: Executable - Provides an executable application. This project type folder contains three templates. Hello World C++ Example provides a simple C++ Hello World application with main(). Hello World ANSI C Example provides a simple C Hello World application with main(). Empty Project provides a single source project folder that contains no files. After you select this template, the result is a project with only the meta-data files required for the project type. You are expected to provide source files for the project's target. The makefile for the Executable project type is automatically created by the CDT.
- Shared Library - An executable module that is compiled and linked separately. When you create a project that uses a shared library (libxx.so), you define your shared library's project as a Project Reference for your application. For this project type, the CDT combines object files together and joins them so they're relocatable and can be shared by many processes. Shared libraries are named using the format libxx.so.version, where version is a number with a default of 1. The libxx.so file usually is a symbolic link to the latest version. The makefile for this project type is automatically created by the CDT.
- Static Library - A collection of object files that you can link into another application (libxx.a). The CDT combines object files (i.e. .o) into an archive (.a) that is directly linked into an executable. The makefile for this project type is automatically created by the CDT.
- Makefile Project - Creates an empty project without the meta-data files. This selection is useful for importing and modifying existing makefile-based projects; a new makefile is not created for this project type.
Upvotes: 3