[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
     Simon

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

FEATURES_REQUIRED += cpp

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../RIOT

# 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
CXXEXFLAGS += -Os -Wall $(INCS) $(LIBS) $(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
/home/simon/git-repos/riot-cpp-wrapper/bin/native/riot-cpp-wrapper.a(main.o): 
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 
`testing::UnitTest::GetInstance()'
main.cpp:(.text.startup.main+0x23): undefined reference to 
`testing::UnitTest::Run()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make: *** 
[/home/simon/git-repos/riot-cpp-wrapper/../RIOT/Makefile.include:276: 
all] Fehler 1


More information about the users mailing list