diff --git a/Documentation/implementation/kernel_modules_vs_shared_libraries.rst b/Documentation/implementation/kernel_modules_vs_shared_libraries.rst index 33c1d3e5f16..e945f98f09f 100644 --- a/Documentation/implementation/kernel_modules_vs_shared_libraries.rst +++ b/Documentation/implementation/kernel_modules_vs_shared_libraries.rst @@ -57,6 +57,31 @@ as the application that uses the shared library. So, they are shared in the sense that the ``.text`` is shared. +Building a Shared Library +========================= + +Applications can declare a loadable shared library with the Android.mk-style +helper in ``nuttx-apps``. Include ``Make.defs``, set the module name and its C +or C++ sources, then include ``BUILD_SHARED_LIBRARY``:: + + include $(APPDIR)/Make.defs + + LOCAL_PATH := $(CURDIR) + LOCAL_MODULE := my-new-lib + LOCAL_SRC_FILES := my-source-file.cpp another-file.cpp + + include $(BUILD_SHARED_LIBRARY) + +The build writes the relocatable ELF library to +``$(BINDIR)/$(LOCAL_MODULE)``. Set ``LOCAL_MODULE_FILENAME`` when the runtime +interface requires another name, such as ``libmy-new-lib.so``. + +``LOCAL_CFLAGS``, ``LOCAL_CXXFLAGS``, ``LOCAL_LDFLAGS``, and ``LOCAL_LDLIBS`` +add module-specific options. The selected architecture must provide the NuttX +module compiler and linker flags. Exported symbols must have default +visibility for ``dlsym()`` or use by another library. + + FLAT Build ==========