Including .a library via LIBS variable and user makefile for offline compile?

I am having a little trouble here: I cannot seem to figure out how to correctly use the LIBS argument described in the build system documentation, for linking in a library in .a format, in the context of an offline compile.

As a test, I set up user/applications/myapp/myapp.cpp as:

#include "application.h"

extern void mylibfunc(void);

void setup(){
    mylibfunc(); //should cause unresolved symbol
}

void loop(){}

and user/applications/myapp/myapp.mk as just:

LIBS += myapplinkedlib

Building with: make PLATFORM=electron APP=myapp indeed yields an unresolved system error, as expected.

However, checking the output from the build process, it looks like there is no attempt to include any “myapplinkedlib” references (expecting libmyapplinkedlib.a) either at the app compile stage or at the final link stage.

The workaround described here did indeed work:


but considering the documentation states that LIBS should be a place to list library archives for inclusion, I wanted to ask if I was doing something wrong.

makefiles are so hard to figure out, but from what I can glean from running with --debug=v, my guess is that module-defaults.mk is getting included before the user makefile, myapp.mk here, so the expansion of my specified LIBS into an LDFLAGS addition is getting done before my requested LIBS are set.