[riot-users] Linking against gtest with RIOT and C++ compiler

Simon Brummer simon.brummer at posteo.de
Tue Feb 14 14:32:22 CET 2017

Hi everybody,

I am doing some small experiments with C++ under RIOT and I would like 
to use gtest on native.
I can't seem to get the linkage against gtest right. Has anyone done 
this before or can show me whats wrong with my make file?

Kind regards

------------  Make Files Contents --------------------------
# name of your application
APPLICATION = riot-cpp-wrapper
BOARD ?= native
CXX = clang++


# This has to be the absolute path to the RIOT base directory:

# Set Flags Compiler Flags
FLAG_1 = -fno-exceptions
FLAG_2 = -fno-rtti
FLAGS += $(FLAG_1) $(FLAG_2)

# Include
INC_1 = -Iinclude
INC_2 = -I../googletest/googletest/include
INCS += $(INC_1) $(INC_2)

# External Libs
LDFLAGS = -L../googletest
LIB_1 = -lpthread
LIB_2 = -lgtest
LIBS += $(LDFLAGS) $(LIB_1) $(LIB_2)

# Assemble Compiler Flags

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include

------------ Console Output --------------------------
Building application "riot-cpp-wrapper" for "native" with MCU "native".

"make" -C /home/simon/git-repos/RIOT/boards/native
"make" -C /home/simon/git-repos/RIOT/boards/native/drivers
"make" -C /home/simon/git-repos/RIOT/core
"make" -C /home/simon/git-repos/RIOT/cpu/native
"make" -C /home/simon/git-repos/RIOT/cpu/native/periph
"make" -C /home/simon/git-repos/RIOT/drivers
"make" -C /home/simon/git-repos/RIOT/sys
"make" -C /home/simon/git-repos/RIOT/sys/auto_init
In function `main':
main.cpp:(.text.startup.main+0x16): undefined reference to 
`testing::InitGoogleTest(int*, char**)'
main.cpp:(.text.startup.main+0x1b): undefined reference to 
main.cpp:(.text.startup.main+0x23): undefined reference to 
collect2: Fehler: ld gab 1 als Ende-Status zurück
make: *** 
all] Fehler 1

More information about the users mailing list