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

Using both c stdio and zephyr stdio

Hello,

I am developing an application that requires use of some of the traditional C "stdio.h" functionality. My current development setup is the nRF5340 DK running Zephyr OS v2.7.99. I am attempting to use the dr_libs libraries, particularly dr_wav at the moment, for decoding audio files. These libraries depend on standard C stdio.h, and I am unsure how to properly include this and other standard C headers in my project. I currently have dr_wav.h placed in my app src right next to src/main.c. I'm also unsure the best way to keep external sources separate from my own in the project organization.

So far I have tried adding the include path (from the toolchain) to my project by using "include_directories()" in my CMakeLists.txt:

And VS Code will now recognize that there are two stdio.h available, one from zephyr and one from standard C:

But still, when trying to call dr_wav_init_file() in main.c, I get the following build errors:

My question is then, what is the appropriate way to enable use of some of the standard C libraries in my project and remove these dependency issues? Any guidance is greatly appreciated, and please let me know if I can provide any more information to help.

Parents
  • These seems like linker error. So most likely the compiler found the declarations from your C files, but is not able to find the definitions of those while linking.
    Check the example \zephyr\samples\application_development\external_lib and check the CMakeLists.txt file. You will have to use add_library to import external library and not just the header files.

Reply
  • These seems like linker error. So most likely the compiler found the declarations from your C files, but is not able to find the definitions of those while linking.
    Check the example \zephyr\samples\application_development\external_lib and check the CMakeLists.txt file. You will have to use add_library to import external library and not just the header files.

Children
  • Hello, thank you for the reply. I have looked into your suggestion. Do you mean to follow the application_development example and import the dr_wav.h external library or import the C stdio.h as an external library? I have tried both but am not sure where to point the src_dir because in the case of dr_wav.h there is no other source, and in the case of the C standard lib I am not sure where to find the actual definitions in the toolchain.

  • Those libraries seems to be outside the scope our solutions so I am guessing that you need to install/include this library from other sources. I can see that MinGW or GLFW might have these libraries included. Once you have install them, 

  • Hi, the fix I found was to set

    CONFIG_NEWLIB_LIBC=y in proj.conf to enable use of the non-minimal c functionality. Although I ended up not needing this functionality. Thank you for the help.