Checking for library present (compiled/being compiled)


I’m working on library X, a feature I would like to add depends on library Y being present; but its presence depends on application developer (user)'s choice
How can I know if library Y is being compiled ?

if (mgos_sys_config_get_libY_enable()) {   // if libY is enabled
    const char *sf = mgos_sys_config_get_libY_somekey();  // get somekey defined there

but the app developer may choose not to include rpc-gcp and those function calls are not available
A mechanism for providing weak stubs ?
Any preprocessor trick ?
Something on the YAML file ? Perhaps defining those config keys myself is a bit too invasive…
Parsing the config file instead ?


If the library is included in the firmware, a macro MGOS_HAVE_LIBNAME is defined and you can use in conditional compilation.
Have a look at build/gen/

// add a cron job
1 Like

Good one!
Thanks, will check that.