How to include properly external pkges


Can somebody help me with the includes? I have an external folder for my packages and defined it as mentioned in the docs.

USEPKG += muscleConfigBuild

The Makefile.include looks like that, but as soon I comment out the includes line, all other includes get messed up.

USEPKG_INCLUDES_muscleConfigBuild := $(LAST_MAKEFILEDIR)/include
#INCLUDES += -I$(USEPKG_INCLUDES_muscleConfigBuild)

And with no includes, I cant include the headers I need for my project. I know there are older topics with answers, but the answer are not displayed anymore bizarrely.

The Makefile looks like that:


include $(RIOTBASE)/pkg/

	$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(RIOTBASE)/Makefile.base

Hi, from a first glance it looks all right what you are doing. What do you mean by


Are there maybe name conflicts with existing header files in the include/ folder of your package?

Hi benpicco

Thanks for the answer.

I had the problem on Sunday that the system wanted to do all the includes over my pkg folder, but since I tested this morning this doesn’t happen again…

But I have the problem now that the git repository gets not builded correct (or it looks like it…)

Is there the possability to include directly the static library as pkg?

Thanks in advance for your help

It’s a bit hard to tell what’s going wrong without the error message / access to the code. If you have an .a archive file you want to link, you can add it to ARCHIVES += /path/to/my_lib.a

Thanks a lot.

It was an error because of the usage of make -j I didn’t see that it was always loading the same package and thought it would include all the other librarys over the same place … Sorry for the misunderstanding

Hey @benpicco

Can I ask you something about shared librarys in RIOT?

I want to add json-c I generated a pkg in my own folder, and added the kconfig, Makefile, and the Makefile.include.

The json-c library gets downloaded and put under build. I have the problem that now a config.h is missing. For the Installation of json-c the following things get described:

Build instructions:

json-c GitHub repo:

$ git clone
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c   # See CMake section below for custom arguments

Note: it's also possible to put your build directory inside the json-c source directory, or even not use a separate build directory at all, but certain things might not work quite right (notably, make distcheck)


$ make
$ make test
$ make USE_VALGRIND=0 test   # optionally skip using valgrind
$ sudo make install          # it could be necessary to execute make install

Now I dont get why the config is missing, could it be that some parts aren’t build? Sorry I’m a bit new to makefiles, make, and cmake

If you follow those instructions you are building json-c as a shared library for Linux. There is no dynamic linking on RIOT and it’s also not compatible with Linux binaries. You’ll need to statically link the library with RIOT and integrate it into the RIOT build system to build it for your target hardware.

There is already the jsmn library packaged in RIOT, maybe you can just use that instead.

But I can build it also as static library if in the CMakeLists.txt the option BUILD_STATIC_LIBS is turned to on 1

Do you have an recommendation document to learn to adapt the cmake and make files over the pkg building?

And thanks again for the quick answers