Linking against gtest with RIOT and C++ compiler

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

Hi,

Hi,

Okay now I got a different error. It seems my build googletest library seems to be incompatible. Any thoughts?

Thanks in advance.

Simon

--- 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 /usr/bin/ld: skipping incompatible ../googletest/libgtest.a when searching for -lgtest /usr/bin/ld: cannot find -lgtest 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 [simon@archlinux-xfce riot-cpp-wrapper]$

It looks like it is not installed.

I have buildt it from the sources and "../googletest" contains a libgtest.a. So the linker should find it. What concernes me more is the "skpping message" before

"/usr/bin/ld: cannot find -lgtest"

Yeah … right … http://stackoverflow.com/questions/3119714/skipping-incompatible-libraries-at-compile

So just check the architecture and make sure it’s compiled correctly?

Okay since i am working on a 64bit Maschine and from the 32bit dependencies for working on native, I think my gtest library is 64bit. This seems to cause all my trouble.

I look into that, thanks for the help.