Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Project setup for navigating existing C/C++ code
Project setup for navigating existing C/C++ code [message #1822046] Wed, 26 February 2020 10:03 Go to next message
Jacob Berggreen is currently offline Jacob BerggreenFriend
Messages: 2
Registered: February 2020
Junior Member
Hi everyone

My background

I'm very new to using Eclipse CDT. I've used JDT quite a lot, though. I have some questions getting started. Hope you can help me.

Goal

For starters, I'd like to use Eclipse for browsing and navigating existing C/C++ code. I've found JDT quite superior in this and I hope to achieve the same with CDT.

I would like to ignore build tool settings and simply use Eclipse for parsing the code and showing warnings/errors and for navigating using F3 etc. Is this possible? Otherwise, I'd like some help setting this up too.

Out of tree project

I'd like to keep the .project file outside of the source tree, so I intent to use "Linked Resources". This option seems to be "grayed out" but I have managed to manually place it in the .project file. Can you explain why it is grayed out?

What I did

I hope you can guide me to a good start. I've tried, on and off, for a few days now, with different project types, and I can't seem to get it working very well.

The projects I work with are mainly a mix of make and cmake projects, using ARM compiler or MinGW GCC.

Example 1: C/C++ code using ARM compiler. I get a lot of "Symbol 'X' could not be resolved." although include paths seem to be set up correctly. F3 works most of the time, even on the "unresolved" symbols.

Example 2: C code using "Zephyr Project", also targeting ARM. Very simple code but I can't get Eclipse to accept my #include statements, e.g. #include zephyr.h even though I set up the include path.

If it would help, I can try setting up a project with details on how I did so it's easier to reproduce, but I'd like to get started in the right way first.

Questions I'd like answered - you probably know better :)

* Which project type to choose?
* Is it possible to use Eclipse only for parsing the code and navigating, i.e. with no build tools?
* How to diagnose problems like "Symbol 'X' could not be resolved."?
* What is the difference between "Create a new C or C++ project" and "Create a Project" -> "C/C++"?
* How to set include paths?
* Why is "Linked Resources" grayed out?

Thank you in advance.
Jacob
Re: Project setup for navigating existing C/C++ code [message #1822084 is a reply to message #1822046] Thu, 27 February 2020 03:20 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You want to import your project as a makefile project instead of creating a new one.
File --> Import --> C/C++ --> Existing Code as a Makefile Project
A Makefile Project doesn't use a tool chain .
The tool settings are only to supply Eclipse with enough information to create a Makefile.
Since you have your own Makefiles, they are irrelevant.
In fact, the tab for altering them doesn't exist in a Makefile project.

If you want syntax analysis and to resolve things like "X could not be resolved"
You need to ensure the include paths are present in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
There are several providers that utilize scanners to discover the paths.

The primary ones that will interest you are the compiler builtins and user entries.
You can only edit the user entries.

The compiler builtins execute a compiler run with special parametes and are actually GCC-centric.
Some compilers won't tell you what has been built into them (Microsoft Visual C products, e.g.)
If you have a tool chain, this provider will use the compilers from the tool chain,
But you can edit the command used if you have no toolchain or your compiler is not a GCC-derivative

Read the help file for more.
https://help.eclipse.org/2019-12/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_scanner_discovery.htm?cp=10_4_7_0_4_6

This may also be helpful but may be somewhat out of date.
I've only skimmed it.
https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php

[Updated on: Thu, 27 February 2020 03:29]

Report message to a moderator

Re: Project setup for navigating existing C/C++ code [message #1822094 is a reply to message #1822084] Thu, 27 February 2020 07:50 Go to previous messageGo to next message
Jacob Berggreen is currently offline Jacob BerggreenFriend
Messages: 2
Registered: February 2020
Junior Member
Thank you so much for your help, David.

I've done what you suggested and now have the following issues:

My .cproject and .project Eclipse files have ended up inside the source tree. Is there a way to avoid this? Maybe, I can create a new Makefile project and then use "Linked resources"? I've tried "Create a Project" but there's no new Makefile project type. I've tried "C/C++ Project" and then there is a "Makefile project" but it says it's Experimental and uses CDT's new Core Build System. Can you help me here?

The "Preprocessor Include Paths, Macros, Etc." properties don't allow me to change anything. All buttons, expect "Move up" and "Move down" are grayed out, both in "Entries" and "Providers" tab. I can, however, use the "Paths and Symbols" properties page and add include paths here. That seemed to work. Can you help me explain the difference?
Re: Project setup for navigating existing C/C++ code [message #1822123 is a reply to message #1822094] Thu, 27 February 2020 15:52 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The only real difference between a Makefile Project and a Managed Build Project is
the "Generate Makefile automatically" setting in Properties --> Project --> C/C++ Build --> Builder Settings tab
Disabling it sets the project as a Makefile Project.
You could create a C/C++ project then import the code but importing as a Makefile Project does all of that for you.

re: linked resources
What I have done in the past was to create a system folder and add files with soft links.
You can try using linked resources
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-45.htm
I think this creates the equivalent of soft links in the .project files.

I don't know why User Entries Add would be grayed out.

As far as I know, the Paths and Symbols tabs are to group tool settings and Preprocessor ... entries into one place.
Using them requires the "Preprocessor Include Paths, Macros, Etc." Managed Build Settings provider.

If you can't add links to User Entries using "Paths and Symbols" looks like a workaround.
Previous Topic:AVR32 hardware debug
Next Topic:File System Directory container in Edit Source Lookup Path option is NOT WORKING
Goto Forum:
  


Current Time: Thu Sep 19 07:39:49 GMT 2024

Powered by FUDForum. Page generated in 0.04568 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top