0

I'm having to use Eclipse for an existing C project that I am adding to and modding and I cannot work out how to set up include paths so I don't have to do things like this:

#include "../other_folder/foo.h"

I have gone into:

Project Properties | C/C++ General | Paths And Symbols

And selected Includes Tab.

Then selected GNU C for the language and then added relative paths. So, for example, added /other_folder into the list of include paths.

However, I still have to put the relative path in for the headers in the source code.

Am I asking for something Eclipse just can't do in expecting to be able to add these paths and be able to do:

#include "foo.h"

rather than

#include "../other_folder/foo.h"

In any source file?

I've even tried putting absolute paths in the project includes, rather than relative paths, but that doesn't work either. What is even weirder is Eclipse gives a message that relative paths are ambiguous!

I have seen this:

Eclipse can't find header file, even though include paths are set

But his solution isn't relevant to this, that wrench thing doesn't show for me. I've trawled through other similar posts, but can't find anything in them that points to what I'm doing wrong.

An example of an output from the compiler if I don't put the path in the source code for a specific issues is this:

Info: Compiling Registers/registers.c to obj/default/Registers/registers.o
nios2-elf-gcc -xc -MP -MMD -c -I../USB3_Controller_BSP//HAL/inc -I../USB3_Controller_BSP/ -I../USB3_Controller_BSP//drivers/inc  -pipe -D__hal__ -DALT_NO_INSTRUCTION_EMULATION -DALT_USE_SMALL_DRIVERS -DSMALL_C_LIB -DALT_SINGLE_THREADED    -O -g -Wall   -mno-hw-div -mhw-mul -mhw-mulx -mgpopt=global  -o obj/default/Registers/registers.o Registers/registers.c
Registers/registers.c:2:22: fatal error: pc_comms.h: No such file or directory

I think the -I is the include paths which does suggest it's just not seeing the include paths I have added. Not sure about the double forward slashes either. eg:

/USB3_Controller_BSP//drivers/inc

That seems odd.

On top of all this, if i delete all entries from the include paths, it keeps telling me there's a whole host of invalid paths such as:

Description Resource    Path    Location    Type
Invalid project path: Include path not found (/home/me/Software/company/USB_Controller_Software/software/USB3_Controller/USB3_Controller/comms).    USB3_Controller     pathentry    Path Entry Problem

Anyone have any suggestions as to what I'm doing wrong please? I suspect I'm missing something fundamental here in the way Eclipse sets up include paths.

(Please don't have a go about the mixed styles of directory naming and file naming, this is not of my doing!)

FWIW Using Mars.2 on Linux for NIOS.

DiBosco
  • 838
  • 8
  • 21
  • Eclipse Mars is 14 releases and more than 5 years behind. – howlger Mar 28 '21 at 18:27
  • That may be, but I am stuck with it. You just can't imagine the world of pain updating to later version of Quartus/NIOS tools for an old project. Even if I wanted to upgrade, I'd not be allowed to. It's actually Mars.2 FWIW – DiBosco Mar 28 '21 at 18:33
  • What kind of project is this? Did you tell Eclipse to generate the Makefile for you? Or do you provide the Makefile yourself? Note that the IDE and the compiler are different systems, and the IDE can only be so smart as you allow it to be. – the busybee Mar 28 '21 at 20:21
  • i have done nothing with it. Although I have written code for many year, this is my first time with NIOS Eclipse and ony my second time ever with Eclipse. This project was created some time ago by someone who isn't a software engineer and it is fair to say it's cobbled together. So it sounds like I need to investigate make files and whether they are autogenerated? I've never had to touch make files in an IDE before. This obviously never occurred. – DiBosco Mar 29 '21 at 00:03
  • And, when you ask what kind of project is it. It's a pure C project with a soft core processor programmed into an FPGA. Is that what you mean? – DiBosco Mar 29 '21 at 00:08

0 Answers0