Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sd_app_evt_wait linker undefined reference when code is in a library, workaround is put it in main

If I use sd_app_evt_wait in a library, I get a link error: undefined reference. A workaround seems to be: don't use it in a library.

In a library (an archive, foo.a):

#include <nrf_soc.h>
void foo() { uint32_t error = sd_app_evt_wait(); ... }

It compiles OK, but when library is linked with main that calls foo(), gives the error above. "nm foo.a" shows that sd_app_evt_wait is "U" (undefined)

I am giving a workaround, I don't need an answer. But it would be nice to understand the problem. My best guess is something about the way the SVCCALL macro attributes the definition of sd_app_evt_wait as "unused". I don't think it depends on sdk_config.h, I think I use the same sdk_config in both cases.

Using SDK14.2, Linux, C++, GNU ARM 6.3.1

Related