CI unit test gtest fail: undefined reference to `pthread_setspecific'

Hi,
I have a project with unit tests with google tests.
Locally everything is ok but on CI(GitHub actions) I have something like this:

Does anyone have something like this?
I see the problem with testing::internal::ThreadLocal but some information that I found relates to other makefiles :confused:
Is this a PlatformIO problem or something with gtest?

Please follow the official documentation GoogleTest — PlatformIO latest documentation

  1. Remove lib_deps
  2. Change testing framework
  3. Restructure your “test” folder into the multiple test suites Test Hierarchy — PlatformIO latest documentation

After a few days I back to this, and try something like You mention, but I have one problem.

Local and on CI I got:

.pio\build\seeed_wio_terminal_test\lib54d\libgoogletest.a(gtest-filepath.cc.o): In function `testing::internal::FilePath::CreateFolder() const':
gtest-filepath.cc:(.text._ZNK7testing8internal8FilePath12CreateFolderEv+0xa): undefined reference to `mkdir'

I found something similar Hot/Cold build problems on Linux with GCC 9.2.0 · Issue #176 · purduesigbots/pros · GitHub but I don’t know it’s good way?

Please remove CUSTOM GOOGLE LIBRARY from lib_deps

lib_deps = 
	google/googletest @ ^1.10.0

But now I use this env

[env:seeed_wio_terminal_test]
platform = atmelsam
board = seeed_wio_terminal
framework = arduino
build_src_filter = -<main.cpp>
test_framework = googletest

[env]
test_framework = googletest

and run

      - name: UT
        run: pio test -e seeed_wio_terminal_test

and I have no idea why this locally working fine

[env:UT]
platform = native
lib_compat_mode = off
src_filter = -<main.cpp>
lib_deps = 
	google/googletest @ ^1.10.0

and this, give me error with heap allocation

[env:seeed_native_test]
platform = native
build_src_filter = -<main.cpp>
test_framework = googletest

Program errored with 3221226356 code

the problem is in you gcc version
gcc version is 8 for the embedded env
but in the native env, it is your computer gcc version (which is 6)
you should install a higher version of gcc

  1. Install MSYS2: If you haven’t already, you need to install MSYS2. You can download the MSYS2 installer from the official website: https://www.msys2.org/
  2. Update MSYS2: After installing MSYS2, open the “MSYS2 MinGW 64-bit” or “MSYS2 MinGW 32-bit” shell from your Start menu. Run the following commands to update the package databases and the system itself:

bashCopy code

pacman -Syu
  1. Install GCC: To install GCC using MSYS2, you can use the package manager pacman. Run the following command to install GCC along with other development tools:

bashCopy code

pacman -S mingw-w64-x86_64-toolchain

This command installs a complete toolchain including GCC, linker, and other essential tools.
4. Confirm Installation: After the installation is complete, you can confirm that GCC has been installed by running the following command:

bashCopy code

gcc --version

This should display the version information of the GCC compiler that you installed.

Remember that when you open the MSYS2 terminal, you might need to use the appropriate “MinGW” shell depending on whether you installed the 32-bit or 64-bit version. You can find these shells in your Start menu.

Note: MSYS2 provides a package manager (pacman) that allows you to easily install and manage software packages. It’s important to keep your MSYS2 installation updated to ensure you have the latest packages and bug fixes.

Additionally, make sure to consult the MSYS2 documentation or community resources if you encounter any issues during the installation process. The installation steps might be updated or changed over time, so it’s always a good idea to refer to the official sources for the most accurate instructions.
then update your varables env