How to compile project with include and src folders

Hi nRF Team,

We are using nRF52832 with nRF5_SDK_17.1.0_ddde560. Our project is growing bigger and we need to separate the header and source files into different folder for better management. We wanted to split .h files into include folder and .c files into src folder. However, doing so will throw this error when we compile the project

make: *** No rule to make target '../../../custom_file.c', needed by '_build/nrf52832_xxaa/custom_file.c.o'.  Stop.
make: *** Waiting for unfinished jobs....

I believe we need to modify a file to allow the compile to know this change of path. I understand that the target should be

'../../../src/custom_file.c'

instead of 

'../../../custom_file.c'

However, I don't know where to change this. Can you please show me how to do so?

I already updated the Makefile to something like 

$(PROJ_DIR)/src/custom_file.c \

Best regards,

Xander

Parents Reply
  • Hi Xander,

    Quick shot in the dark, can you try deleting the _build directory entirely?

    $(PROJ_DIR)/src/custom_file.c \

    should have been all you need.

    Given your output log states

     

    "'../../../custom_file.c'"
     

    it seems like

     

    $(PROJ_DIR)/custom_file.c \ 

    is what it tried to do.

    I very briefly tested the in an existing application with identical folder structure to your opening post (src/ and include/ directories added to put the files in there), and the only addition I needed was   $(PROJ_DIR)/src/custom_file.c \ under the SRC_FILES += \ list.

    Best regards,

Children
Related