Preprocessor Include Paths, Macros etc. entry not available - c

I can't navigate through a project in Eclipse (Oxygen.3a Release (4.7.3a) with CDT version 9.4.3.201802261533). The project is built successfully but I can't trace back many functions using ctrl+LMclick.
I tried fixing the problem from online resources, but many suggested modifying the entry of Preprocessor Include Paths, Macros etc, which my project does not even have. What is the reason behind this and how do I fix it?
For some reason, the next entry (C/C++ Include Paths and Symbols) shows that |Include path not found"
When I try to trace a function, I get the "Could not find symbol "xyz" in index". I have already tried rebuilding the indexer but it did not work for me.

In my experience, the absence of the Preprocessor Include Paths, Macros etc. preference page happens in newer versions of CDT when you select the new Makefile Project option in the new project wizard, whose description is
(Experimental) Create a new project that builds with the 'make' build
tool using CDT's new Core Build System.
I would avoid using this as it's experimental, and would select instead C Managed Build (or C++ Managed Build). On the next wizard page you can still make it a makefile project if you want.

I ran into this problem trying to use cmake4eclipse. I forgot to heed the warning in the help file, which explicitly state:
"Do not choose the New C/C++ project wizard, as that will take you down the road of CDT`s new project type (which has poor cmake support)."
What this means is that, for the entry to appear in an executable / library -type project (not Makefile project), you have to do this now:
File --> New --> Other...
Choose "C++ Project" (not "C/C++
Project") under the C/C++ category:
P.S. Also, I had to remake the folder and copy all the sources there, i.e. when I tried the old wizard on top of a "deleted" project, something didn't override correctly and I was still missing "Preprocessor Include Paths, ...". Deleting .cproject and .project files within the folder before recreating works too.

Depending on your project, you may need to include the path of the toolchain manually. It wasn't for me. So for my project I did the following:
Go to Project – Properties – C/C++ Include Paths and add there “C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\arm-none-eabi\include” (change to fit your installation). Then refresh, clean and build the project. Finally, rebuild the indexer and this should work.

Related

How do I create a CMakeLists.txt?

I am starting to learn about CMake and have two questions:
1. Do I need to update the CMakeLists.txt file every time When I add a new file?
Assuming that the size of the project grows, the number of subdirectories and source files in the project will also increased greatly.
In such a case, I guess it is inconvenient to update the CMakelists.txt file whenever a new file or directory is added to the project.
Or is it part of the code management? How is it usually done?
2. In order to build a C Eclipse project(makefile) using CMake, should I write the CMakeList.txt manually?
There are many ways to import CMake projects into Eclipse, but I can't see how to build a C Eclipse project with CMake.
Do I need to update the CMakeLists.txt file every time When I add a new file?
CMake, like GNU make, allows to use wildcards to specify source files.
However, it's good practice to explicitly list files to build, in order to avoid silly mistakes (due, for example, to missing or unexpected files in source directory).
When file list becomes large, build definition files (like CMakeLists.txt) may be split into multiple files.
In order to build a / C Eclipse project(makefile) / using CMake, Should I write CMakelist.txt manually?
I don't know aboud Eclipse, but many IDEs partially/completely automate CMakelists.txt creation. Maybe Eclipse has such a tool too.
Yes write your CMakeLists.txt manually. This can barely be automated, beside adding new header files. There is a way to include all *.h files, but it is not enouraged.
And add every new header file manually. C files are not needed. Adding header files should not happen ofen.
Writing your own CMakeLists.txt files is recommended (at least you understand how CMake works). However, for larger projects it makes sense to automate it. I decided to post my own CMake generator https://github.com/Aenteas/cmake-generator so anyone who wants to implement their customized version could adopt some ideas from here (as it is not likely that my generator would suit your needs perfectly).

What do I need to leave out of Git for Eclipse CDT Projects

I have a project that has it's include files pretty much in the project folder...I don't use anything that's in, say, /usr/lib...It's all in ./whatever.
I'd like to share a project, with the intent that people will import it into Eclipse and then will be able to go from there. However, this never works right, because when I push changes, my environment variables get pushed too. This breaks other peoples projects when the pull from Git.
What do I need to exclude from revision tracking to make sure that the environment variables don't get changed with each remote push, but that things like new Include Paths do?
Thanks
From my experience, do not include
.project
.cproject
.settings/org.eclipse.cdt.codan.core.prefs <- CDT support stuff
.settings/org.eclipse.core.resources.prefs <- file encodings
.settings/org.eclipse.core.runtime.prefs <- line terminators
in .gitignore. This will reduce the fidelity of importing your project within your team. Files to consider including:
.buildpath <- system specifics
.settings/org.eclipse.cdt.core.prefs <- system specifics
I truly wish CDT was a bit more relocatable friendly (using 6.0 and 8.8).
Good luck
Randall
(Git platform maintainer for NonStop)
You need to add the unwanted files to your .gitignore file. For eclipse I believe your .gitignore must look like
.project
.buildpath

Building a multi module C project (i.e. solution) with Eclipse CDT

I am moving from Netbeans to Eclipse (on Ubuntu 12.0.4). I have a C application that consists of several sub projects which are libraries (shared and static), as well as stand alone executables.
I can't figure out how to create a 'parent' project foo, which contains component projects
foobar
foofoo
barfoo
barbar
Ideally, I want all the 'component projects' to be created under the folder foo, so that I have a directory structure like this:
/path/to/foo/foobar/ (contains foobar project files)
/path/to/foo/foofoo/ (contains foofoo project files)
/path/to/foo/barfoo/ (contains barfoo project files)
/path/to/foo/barbar/ (contains barbar project files)
Does anyone know how I can achieve this structure using Eclipse as IDE (with CDT)?
Last but not the least, I intend to create my C modules using the Autotools option. Will the generated files for Autotools be automatically updated as I add new header/source to a module - or do I need to manually maintain the Autotool files?
Friend,
I think there is no the "parent" C project. You can create a normal C project in IDE and add all dependencies into sub-folders. Then tell compiler your build procedure via Makefile. I think it's easy way as you have had experience on C application.
About autotools, once you update/add/remove your project file, I think you need to modify your Makefile to reflect your change and do clean and rebuild your project.
For other C build tools, you can use buildroot if you'd like.
The best way I can think to do this in eclipse is to create a separate workspace for the project e.g. foo, and then add the sub-projects (foobar, foofoo, etc...) as projects. This is generally a better approach to take with eclipse, instead of a single monolithic workspace. I don't know what the specific dependency structure for the sub-projects looks like, but you should be able to express it simply by using eclipse project properties. This can include a rollup executable sub-project that depends on the libraries.
Unfortunately, I'm not sure if eclipse cdt will maintain autotools files. However if not, it should be relatively easy to integrate and use some of the autotools binaries such as autoscan, and autoheader into the eclipse build commands.
At first you need to a working directory, Then you should new project, Then per file or per class (according to C++ or C ) append your files, it's much safe way. another way is not clean, i have experience. don't use them.

Add external source files from a library to the project in Eclipse-CDT

I have a project which I try to compile with Eclipse-CDT. The project depends on a library with header files and source files. How can I configure the project in Eclipse such that it will compile the needed source files from the library with the project?
With a makefile I use:
SRC+=lib_source.c
You can add linked source file.
Choose project properties and in the left panel choose c++ general.
Under it choose path and symbols.
Now in the right panel tabs choose source location and add linked source folder.
Include you need to define in "include" (under c++ build you will find settings)
Another approach is to use the operating system to add your libraries to the project. Eclipse then treats all source files (including library files) as part of the project, and therefore compiles any that need it even if they are in the libraries. This set-up allows keeping the library sources in a separate git repository from the project source code. You can record the git commit of a library to provide library version control so that improving the library in one project does not break all the others. The setup relies on the operating system's capability to link directories in a way that is entirely transparent to eclipse--in windows using the mklink command.
In windows the steps are
put your library files in a clean workspace not mixed with .git (you can have .git in the parent directory as egit sets it up)
use cmd window in administrator mode to add a link from your project directory to your library directory.
from eclipse press F5 t make sure your project matches what is on disk, then set up git to ignore your library directory.
set up your library file properties for read only access unless you are still tweaking that library.
set up your project include path to include the project sub-directory in your project.
I can't remember why I abandoned eclipse linked directories; i think it was that the includes kept breaking. The mklink approach has worked flawlessly so far.
I have a pdf tutorial of how to set this up--but I'm new to the forum and don't see how to attach a file.

How to correctly setup a C language project in Eclipse

I'm an experienced Java developer, and I'm very familiar with Eclipse. Lately I've been trying to migrate a Texas Instrumental(BLE), IAR C language project, into Eclipse, without using IAR official Eclipse plugin, I just want to use Eclipse as my code browsing IDE, while I learn how things works, and follow up the tutorial, and in the future use Eclipse to develop.
I've been trying for a day now, to migrate the project, but there is something I'm missing something regarding Eclipse C language support.
There are some types defined in an .h file, in project "A", which is referenced in an other .c file in project "B", and Eclipse although it can "go to declaration", it shows a compilation error in project "B".
I've noticed in other cases of the same scenario, that I don't need to point to any of the folders as source folder, as long as the folders are under the project root directory, they are added to the build path of that specific project, and also imported into a project "B" with only referencing the "A" project in the project properties, is this correct?
Also, I've noticed that in the C language both projects could reference each other, without Eclipse troubling me so I assume this is legit, therefore I assume there should be a C language multi-project structural pattern I should follow, where can I find such detailed specification?
Thanks,
Adam Zehavi.
Try this (Common Source Lookup Path preference)
Edit: in my Eclipse CDT Helios, I do like this:
Right click on project > Properties > C/C++ General > Paths And Symbols.
then choose my language (GNU C) and add the folders with the header files that I want to include.
That operation could be done automatically in one step for every configurations (Run/Debug) or just for the active configuration.
I've finally understood that this cannot be done... alas I've worked hard to been able to edit my code in Eclipse while running, debugging, and deploying the program to the Microprocessor via IAR IDE.
Go to Project > Properties > C/C++ General > Paths and Symbols Then click Export Settings... to save the include paths and/or symbol definitions to a file. In your other project, you can then use Import Settings...

Resources