templates: examples: Fix linker invocation for C++

Using g++ to link object files automatically links the STD of C++. It looks
like this library is linked outside of the start/end-group commands with
the other libraries, which causes undefined reference errors when linking
C++ projects that use standard library functions that interface with the
OS, like `fopen()`.

Thanks to @lifehackerhansol for the report and testing the fix.
This commit is contained in:
Antonio Niño Díaz 2024-03-26 18:54:01 +00:00
parent 5ea29c4f81
commit d7ecc5cc4d
4 changed files with 8 additions and 12 deletions

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
export BLOCKSDS ?= /opt/blocksds/core
export BLOCKSDSEXT ?= /opt/blocksds/external
@ -71,6 +71,7 @@ endif
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
LD := $(PREFIX)gcc
OBJDUMP := $(PREFIX)objdump
MKDIR := mkdir
RM := rm -rf
@ -116,10 +117,8 @@ SPECS := $(BLOCKSDS)/sys/crts/ds_arm9.specs
WARNFLAGS := -Wall
ifeq ($(SOURCES_CPP),)
LD := $(CC)
LIBS += -lc
else
LD := $(CXX)
LIBS += -lstdc++ -lc
endif

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
BLOCKSDS ?= /opt/blocksds/core
BLOCKSDSEXT ?= /opt/blocksds/external
@ -70,6 +70,7 @@ endif
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
LD := $(PREFIX)gcc
OBJDUMP := $(PREFIX)objdump
MKDIR := mkdir
RM := rm -rf
@ -115,10 +116,8 @@ ARCH := -march=armv5te -mtune=arm946e-s
WARNFLAGS := -Wall
ifeq ($(SOURCES_CPP),)
LD := $(CC)
LIBS += -lc
else
LD := $(CXX)
LIBS += -lstdc++ -lc
endif

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
BLOCKSDS ?= /opt/blocksds/core
BLOCKSDSEXT ?= /opt/blocksds/external
@ -70,6 +70,7 @@ endif
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
LD := $(PREFIX)gcc
OBJDUMP := $(PREFIX)objdump
MKDIR := mkdir
RM := rm -rf
@ -115,10 +116,8 @@ ARCH := -march=armv5te -mtune=arm946e-s
WARNFLAGS := -Wall
ifeq ($(SOURCES_CPP),)
LD := $(CC)
LIBS += -lc
else
LD := $(CXX)
LIBS += -lstdc++ -lc
endif

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
#
# SPDX-FileContributor: Antonio Niño Díaz, 2023
# SPDX-FileContributor: Antonio Niño Díaz, 2023-2024
BLOCKSDS ?= /opt/blocksds/core
BLOCKSDSEXT ?= /opt/blocksds/external
@ -71,6 +71,7 @@ endif
PREFIX := $(ARM_NONE_EABI_PATH)arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
LD := $(PREFIX)gcc
OBJDUMP := $(PREFIX)objdump
MKDIR := mkdir
RM := rm -rf
@ -116,10 +117,8 @@ ARCH := -march=armv5te -mtune=arm946e-s
WARNFLAGS := -Wall
ifeq ($(SOURCES_CPP),)
LD := $(CC)
LIBS += -lc
else
LD := $(CXX)
LIBS += -lstdc++ -lc
endif