Skip to content

Commit 7176acb

Browse files
committed
py: Add LIBS_USERMOD to LIBS.
This enables C++ modules to correctly postion -l linker flags at the end of the flags instead of at the start. Updated the example C++ micropython.mk accordingly. Signed-off-by: Dryw Wade <dryw.wade@sparkfun.com>
1 parent 4efc5e1 commit 7176acb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

examples/usercmodule/cppexample/micropython.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ SRC_USERMOD_CXX += $(CPPEXAMPLE_MOD_DIR)/example.cpp
88
CFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR)
99
CXXFLAGS_USERMOD += -I$(CPPEXAMPLE_MOD_DIR) -std=c++11
1010

11+
# Add any necessary paths to library files.
12+
# LDFLAGS_USERMOD += -Lpath/to/libs
13+
1114
# We use C++ features so have to link against the standard library.
12-
LDFLAGS_USERMOD += -lstdc++
15+
LIBS_USERMOD += -lstdc++

py/py.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SRC_USERMOD_LIB_ASM :=
4747
CFLAGS_USERMOD :=
4848
CXXFLAGS_USERMOD :=
4949
LDFLAGS_USERMOD :=
50+
LIBS_USERMOD :=
5051

5152
# Backwards compatibility with older user c modules that set SRC_USERMOD
5253
# added to SRC_USERMOD_C below
@@ -69,6 +70,7 @@ SRC_USERMOD_PATHFIX_LIB_ASM += $(patsubst $(USER_C_MODULES)/%.S,%.S,$(SRC_USERMO
6970
CFLAGS += $(CFLAGS_USERMOD)
7071
CXXFLAGS += $(CXXFLAGS_USERMOD)
7172
LDFLAGS += $(LDFLAGS_USERMOD)
73+
LIBS += $(LIBS_USERMOD)
7274

7375
SRC_QSTR += $(SRC_USERMOD_PATHFIX_C) $(SRC_USERMOD_PATHFIX_CXX)
7476
PY_O += $(addprefix $(BUILD)/, $(SRC_USERMOD_PATHFIX_C:.c=.o))

0 commit comments

Comments
 (0)