I don't understand what is exactly a builder in CDT, and what is the relationship with the "C/C++ Build" content.
I set up SCons in the "C/C++ Build" confuguration. It does work : I made two configurations (release and debug), and my SCons scripts are launched. But as I try now to debug, I am studying these Builders stauuf (I am discovering Eclipse...).
The documentation is not clear at all about this point.
Thanks for help.
I'm not exactly sure what your problem is, but I'll try to explain how builders work.
Any Eclipse project has zero or more builders, and they are invoked (in order) when Eclipse builds a project. There are different kinds of builders which do different things, such as invoking an external build tool or validating an XML file. You can define your own builders if you want.
A CDT project typically has two builders. The first one is the CDT builder which is responsible for compiling your code. If you are using an external build tool you are most likely using a "makefile project", in which case the CDT builder simply invokes your build tool for you. This is by default called "make", but you can change it in the project settings.
The second builder is the "scanner discovery" builder. The purpose of this builder is to try to figure out which include paths etc. to use for the indexer so that auto-completion will work, etc. If you are using an external tool, chances are that you will need to set up these yourself under the "Paths and Symbols" tab.
Builders are in general not involved when debugging, but you may run into trouble if the build system doesn't put the compiled binaries in a place where CDT expects. There should be a tab in the project properties where you can configure how/where CDT looks for binaries.
Related
I'm using eclipse to develop my project, which bases on my custom makefile system. I have to use custom Makefile project because I want to tevelop LLVM porject pased on the LLVM makefile system, see: http://llvm.org/docs/Projects.html.
I created an "empty makefile" project in eclipse, I'v chosen the build location (Project->Properties->C/C++ Build->Build Location) and added every needed library sources (Project->Properties->C/C++ General->Paths and sources).
The project build and executes like it should. The problem is that a lot of lines is underscored with red colour as errors. This is obvious because eclipse chcecks for erros executing gcc and it does not executes it unless I'm using Makefiles (or maybe I am wrong ...).
Anyway - is there any way to check for syntax (and other types of) errors while using eclipse with makefiles?
Check out this question, or google "eclipse unresolved symbols". You need to add the paths of your includes to your project settings, so Eclipse editor/indexer can find them.
The question in the link is for unresolved includes, but it also applies to all unresolved symbols.
I'm a new C++ programmer using Eclipse. Eclipse seems to recognize C++: It let me create a new C++ project and understands the syntax. However, whenever I try to #include anything, I get an "Unresolved include" error.
I have CDT installed. I also just installed MinGW and MySys and set the path variables correctly.
It looks like something's still missing from Eclipse though -- when I right click on my project and go to "properties -> C/C++ build -> Settings" all I can access are the "binary parsers" and "error parsers" tabs. The window should look like this...
...but I can't see the tool settings, build steps or build artifact tabs.
That's all my research has turned up so far. What should I do next?
Settings on screenshot related to build process. For correct work editor (autocomlete, includes) you need to set same dirs in the C/C++ General/Paths and symbols, includes, GNU C++. Also, if path variable containt dir with g++ ecplise should to have prepared configuration if you choose mingw toolchain while creating project.
Update for comment
I'm making a DLL (and probably a Linux port at some later date) in C++ using eclipse. The situation is as follows: I am trying to make two separate build configurations, one that will build a DLL and one that will build an executable CppUnit test. Currently I have all of the DLL build working, and I can make a separate project to test the DLL with; however, I was wondering if there was any way to do this all in one project.
Help on this matter would be greatly appreciated!
Thanks,
Chris
Well, I found out how to do it, so if anyone else stumbles across this...
If you go into "Project->Properties->C/C++ Build->Settings", then select a debug configuration (or create a new one). Go to the "Build Artifact" tab, and change the "Artifact Type" to executable.
Now to avoid having all of your source code compiled into all Build Configurations (such as your main() being built into a DLL, which doesn't make much sense), go to "Project->Properties->C/C++ General->Paths and Symbols". Select your build configuration and go to the "Source Location" tab. Here you can add new source folders/remove source folders that already exist.
I don't use Eclipse as an IDE, and have no interest in doing so. However, I do like its source-level debugging.
Is there any way I can use it to debug a C++ Linux app without going through the ritual of creating a project? (In effect, can I just use it like a frontend to gdb?)
If not, what are the steps I need to follow to create a project that I can use to just debug an existing C++ program that is built using Makefiles or other tools (SCons, CMake, etc.). I don't want to be able to "develop" in Eclipse; all I need to do is debug.
Take a look at this question. Create a C/C++-project, use your project's source directory as project directory, select to use the external builder, and change "make" to whatever tool you want.
The tricky part is to get the indexer to work correctly and find all your header files.
EDIT: CMake 2.6.x has support for generating CDT project files, which might be a more straightforward solution.
I don't know if this has changed in the 4+ years since the question was posted, but there's a much easier way to do this. I'm on Eclipse Luna (4.4.2).
> eclipse&
then
File > Import > C/C++ > C/C++ Executable > Next > browse to executable > Next > choose a project name > Finish
No other project setup required, no source paths (which should be in the object code). Just like running gdb/insight/etc. Almost makes it worth installing Java.
Configuration for debugging in Eclipse.
In eclipse,
Go to Window->preferences
A popup will appear then select C/C++ , click on drop down arrow ,then select Debug and click on drop down arrow.
Select Source Lookup Path and then click on Add.
After clicking on Add, click on Path Mapping and then click on OK.
Specify the mapping path name and then click on Add .
In compilation path select Cygwin path (need to install) and then click ok .
In debug option,click on source Lookup Path and select Path Mapping:Project source and click on apply and then ok.
I have a large existing c++ codebase. Typically the users of the codebase edit the source with gvim, but we'd like to start using the nifty IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives without paths due to some voodoo we use in our build process. When I link the source to my project in Eclipse, the indexer complains that it can't find any header files (because we don't specify paths in our includes.) If I manually add the directories from the workspace to the include path then everything works wonderfully, but obviously adding hundreds of directories manually isn't feasible. Would there be a simple method to tell Eclipse to look anywhere in the project for the include files without having to add them one by one? If not, then can anyone suggest a good starting place, like what classes to extend, for writing a plugin to just scan the project at creation/modification and programatically add all directories to the include path?
The way that CDT manages build paths is by looking at the .cdtbuild xml file in the base of your projects directory (it might be a different name on windows... not sure)
In this you should see something like
<option id="gnu.c.compiler.option.include.paths....>
<listoptionValue builtIn="false" value=""${workspace_loc:/some/path}$quot;" />
<listOptionValue ... />
...
</option>
this is where all the build paths that you configure in the gui are placed. It should be pretty easy to add all the directories to this using a simple perl script to walk the project and generate all the listOptionValue entries.
This is obviously not the ideal method. But im curious, what build system are you migrating from, if it is make based you should be able to get eclipse to use your make files.
This feature has already been implemented in the current CDT development stream and will be available in CDT 6.0, which will be released along with Eclipse 3.5 in June 2009.
Basically if you have an #include and the header file exists somewhere in your project then CDT will be able to find it without the need to manually set up include paths.
If you need the feature now you can download and install the latest CDT development build.
Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=213562
Latest CDT 6.0 Builds: http://download.eclipse.org/tools/cdt/builds/6.0.0/index.html
From reading the this Eclipse CDT FAQ entry, it sounds like Eclipse can automatically generate a list of include directories if you start your build from within Eclipse and if your build outputs the gcc / g++ commands before actually starting gcc / g++. You can change how Eclipse starts a build by going under Project Properties then selecting the C/C++ Build category and looking for the Build Command option on the right side of the dialog.
Depending on the amount of voodoo you are doing in your build process, then Eclipse may not be able to correctly parse your source files, especially if you have similarly named headers for different source files. If you really want to take full advantage of Eclipse you're going to need to make sure that with whatever setup you have you aren't going to be confusing the parser. Personally I would recommend having a simple layout and build process.
As for the question at hand, adding the directories one by one is pretty much your best bet.