0

I tried to compile google test framework with MinGW on Windows following instructions from this post, but I got errors when executing make:

[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from d:/downloads/googletest-master/googletest/src/gtest-all.cc:45:0:
D:/downloads/googletest-master/googletest/src/gtest-port.cc: In static member function 'static void testing::internal::ThreadLocalRegistryImpl::StartWatcherThreadFor(DWORD)':
D:/downloads/googletest-master/googletest/src/gtest-port.cc:495:21: error: '::OpenThread' has not been declared
     HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,
                     ^
make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2

Please help. I tried:

cmake -G "MSYS Makefiles" --with-pthreads=no

But got:

CMake Error: The source directory "D:/downloads/googletest-master/googletest/--with-pthreads=no" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

Thanks for answers.

Community
  • 1
  • 1
m3rk
  • 653
  • 6
  • 12

1 Answers1

0
cmake -G "MSYS Makefiles" --with-pthreads=no

I don't think --with-pthreads=no is a valid cmake option. CMake tries to interpret it as the source directory. Remove that option. I think google test needs pthreads anyways, that is why OpenThread is not declared, because it depends on pthreads.

If you're not using the MSYS shell, try to use the "MinGW Makefiles" generator for cmake.

cmake -G "MinGW Makefiles"

Then run make.

larso
  • 138
  • 1
  • 5