Hey,
sorry for the rookie question but I have some problems to include a simple header file from a subdirectory.
First I added a new source folder, so it looks like this:
I added the include path in the project properties
I also edited the makefiles in the upper project folder …
# SRC_DIR sets the path to the program source directory
SRC_DIR ?= $(abspath src)
# HAL_DIR sets the path to the HAL source directory
HAL_DIR ?= $(abspath src/HAL)
PROGRAM_SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.h) $(wildcard $(SRC_DIR)/*.S) $(wildcard $(HAL_DIR)/*.c) $(wildcard $(HAL_DIR)/*.h) $(wildcard $(HAL_DIR)/*.S)
…and in the src folder
PROGRAM ?= HIFIVEHAL
$(PROGRAM): $(wildcard *.c) $(wildcard *.h) $(wildcard *.S) $(wildcard HAL/*.c) $(wildcard HAL/*.h) $(wildcard HAL/*.S)
$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.c %.S,$^) $(LOADLIBES) $(LDLIBS) -o $@
clean:
rm -f $(PROGRAM) $(PROGRAM).hex
But I still get this error:
make[1]: Entering directory '/c/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/src'
/C/Users/.../Documents/FreedomStudio-4.18.0.2021-04-1-x86_64-w64-mingw32/SiFive/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8/bin/riscv64-unknown-elf-gcc -march=rv32imac -mabi=ilp32 -mcmodel=medlow -ffunction-sections -fdata-sections -I/C/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/bsp/install/include --specs=nano.specs -DMTIME_RATE_HZ_DEF=32768 -fcommon -O0 -g -Wl,--gc-sections -Wl,-Map,HIFIVEHAL.map -nostartfiles -nostdlib -L/C/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/bsp/install/lib/debug/ -T/C/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/bsp/metal.default.lds main.c HAL/HAL_GPIO.c -Wl,--start-group -lc -lgcc -lm -lmetal -lmetal-gloss -Wl,--end-group -o HIFIVEHAL
main.c:3:10: fatal error: HAL_GPIO.h: No such file or directory
3 | #include "HAL_GPIO.h"
| ^~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:7: HIFIVEHAL] Error 1
make[1]: Leaving directory '/c/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/src'
make: *** [Makefile:287: /c/Users/.../Documents/FreedomStudio_Projekte/sifive_hifive1_revb_HAL/src/debug/HIFIVEHAL.elf] Error 2
"make all CONFIGURATION=debug" terminated with exit code 2. Build might be incomplete.
I hope someone can help me, thank you!