Unit testing with GTEST/GMOCK on [env:desktop], on Arduino platform

I was so unhappy with all my unsuccessful digging that I decided to install Linux as dual boot and try with build-in gcc/g++. I had completely different errors, this time missing -pthread which I had to add to

build_flags =
-std=gnu++11 # must be gnu++11, not -std=c++11 for gtest to run
-pthread # needed to make gtest run on g++

AND - it WORKED :slight_smile: :slight_smile: :slight_smile:
Back to Win10 (I just couldn’t stand it not working on Windows)
I suspected that MinGW was just not configured correctly.

  • Enter command line Start->cmd
  • type mingw-get (pity that I did not do this earlier!)
  • search for mingw32-libmingwex under MinGW Standard Libraries
  • activate both mingw32-libmingwex-dll and mingw32-libmingwex-dev
  • activate mingw32-libpthreadgc-dll and mingw32-libpthreadgc-dev
  • Installation->Apply Changes

Rebuild with pio test -e desktop -f desktop --verbose
Et Voilà:


Should anyone be interested in a tutorial with complete config of platformio and MinGW for googletest, I’d be happy to help.

1 Like