offsets.h No such file or directory

Hi, 

We have been using SDK version 2.1.1 and currently are in the process of migrating to SDK version 2.5.0.

Would be helpful to get some hint regarding what conditions can lead to the following error when building our application.

In file included from C:\ncs\v2.5.0\zephyr\include\zephyr\app_memory\app_memdomain.h:9,
from C:\ncs\v2.5.0\zephyr\include\zephyr\rtio\rtio.h:31,
from C:\ncs\v2.5.0\zephyr\include\zephyr\drivers\i2c.h:28,
from <our application.h>...
C:\ncs\v2.5.0\zephyr\include\zephyr\linker\linker-defs.h:26:10: fatal error: offsets.h: No such file or directory
26 | #include <offsets.h>
| ^~~~~~~~~~~

Thanks,

Mathi.

  • It's not that weird. offsets.h is generated by the Zephyr build system and once generated it (generally) doesn't change between builds, this is why the bug is only reproducible with a clean build. The weird part is what changed in the Zephyr/NCS build system to generate this file at a different build stage. 

  • This fix didn't work for me. i2c.h was already being included from a .c file (not a .cpp file, if that matters) according to the compiler error. It was also being included from a different header file, so I stripped that out just in case, but it made no difference.

    This issue has come and gone for a long time for us. It came back recently and there's a common smoking gun with reports in this thread:

    The issue appears when I `add_subdirectory()` the file containing the offending #include, and goes away if I add it to `target_sources(app PRIVATE...` instead.

    Specifically, the .c file that includes i2c.h is in a folder with a CMakeLists.txt file that adds it to a library if a CONFIG is defined. If I include the .c file in the list that gets passed to `target_sources()` in the project's base level CMakeLists.txt file, I don't get the offsets.h issue. But I also can't control inclusion using prj.conf. If instead I add the folder with `add_subdirectory()` in the project's base level CMakeLists.txt file I get the normal CMake features like CONFIG control, but the offsets issue appears.


  • Now I'm also facing this same issue. The trigger for this was to include a "add_subdirectory(drivers)" in the project's CMakeLists.txt file.

    Only workaround I found works for me (partly) when making fresh builds is to comment out the line in CMakeLists, the compiler/tools then generate the offset.h file, then uncomment the line and compile again.

    Is there any working solution not involving doing things like these?

    BR

  • Our current solution is to just run the build a few times until it works. It usually requires 3-4 attempts.

  • Five or even more attempts were not enough for my case, so I had to fallback to comment/uncomment the ad_subdirectory() lines in CMakeLists.txt.

    BR

Related