This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

VSCode Includes with custom modules? nCS

Hi Everyone,

I've started working with Zephyr, VSCode and nCS.

I'm using a sample and working on it modifiying things, but I'm not able to include extern modules, lemme explain it;

I've developed some modules that will help in my work, but when I add those to the Workspace and Try to #include it, VSCode cannot find it, also I added the path to the settings.json for the workspace with "C_Cpp.default.includePath" but nothings seems to work, I'm truly lost rn cause I need those modules to keep working...

I hope someone could light me. 

Thanks in advance to everyone,

MatiasP

Parents
  • Hello MatiasP,

    To include custom files in Zephyr you need to add them to your CMakeLists.txt file. You'll need to do the following:

    For header files, add this to the end of CMakeLists.txt:

    zephyr_library_include_directories(src/my_module)

    This will include the path to your include folders. After this, you should be able to include them like normally from your main.c file using:

    #include "my_custom_file.h"

    For source files, you need to add this to the end of CMakeLists.txt:

    target_sources(app PRIVATE
        src/my_module/my_custom_file.c
    )

    If you want to add more files, you can add separate them using ";"

    target_sources(app PRIVATE
        src/my_module/my_custom_file.c;
        src/my_module/my_other_custom_file.c

    I hope that answers your question. If not, please let me know.

    Best regards,

    Edvin

Reply
  • Hello MatiasP,

    To include custom files in Zephyr you need to add them to your CMakeLists.txt file. You'll need to do the following:

    For header files, add this to the end of CMakeLists.txt:

    zephyr_library_include_directories(src/my_module)

    This will include the path to your include folders. After this, you should be able to include them like normally from your main.c file using:

    #include "my_custom_file.h"

    For source files, you need to add this to the end of CMakeLists.txt:

    target_sources(app PRIVATE
        src/my_module/my_custom_file.c
    )

    If you want to add more files, you can add separate them using ";"

    target_sources(app PRIVATE
        src/my_module/my_custom_file.c;
        src/my_module/my_other_custom_file.c

    I hope that answers your question. If not, please let me know.

    Best regards,

    Edvin

Children
No Data
Related