This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding header and source files to nRF Connect SDK Project

Hello all,

I am working on a custom application that requires gps, https post requests, SPI, and CAN, and I am having trouble adding source and header files to my project. Following the tutorial on the nRF Connect SDK documentation page, I am trying to add a new file to CMakeLists.txt by right clicking on Project 'app/libapp.a' , but sometimes the option to add a new file isn't available. Depending on which project you start with, there is no option to add new files to Cmake, which is strange.

I eventually found an example that allowed me to actually add files to CMake (at_client), but am now getting multiple errors and multiple stages of building. How can I add .h and .c files to CMakeLists.txt?

I have searched through devzone looking at examples but don't see a clear step by step manual for adding .c and .h files to an nRF Connect SDK project. Some examples say to add to the 'src' folder, but nowhere do I see a src folder. On most other IDEs I just create new folders for my header and source files and just add them there, but this doesn't seem to link correctly. Any help would be appreciated, thank you.

-Kyle Garland

Parents
  • Hi, Kyle!

    This is unfortunate behavior. I will take further internally. In the meantime I recommend doing the addition of header and source files manually by:
    1. Navigating to the project folder either using the file explorer or a terminal. 
    2. Placing your .c files in the src folder located there.
    3. Making an "include" folder where you place your header files.
    4. Edit CMakeList.txt directly as described in our sample modification guide.

    Note that you may need to reload your SES project after changing CMakeLists.txt.

    Hope this helps!

    Best regards,
    Carl Richard

Reply
  • Hi, Kyle!

    This is unfortunate behavior. I will take further internally. In the meantime I recommend doing the addition of header and source files manually by:
    1. Navigating to the project folder either using the file explorer or a terminal. 
    2. Placing your .c files in the src folder located there.
    3. Making an "include" folder where you place your header files.
    4. Edit CMakeList.txt directly as described in our sample modification guide.

    Note that you may need to reload your SES project after changing CMakeLists.txt.

    Hope this helps!

    Best regards,
    Carl Richard

Children
Related