Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error on master using MinGW 8.2.0 and MSYS #2630

Open
Kravlalala opened this issue Dec 12, 2019 · 2 comments
Open

Compilation error on master using MinGW 8.2.0 and MSYS #2630

Kravlalala opened this issue Dec 12, 2019 · 2 comments
Assignees

Comments

@Kravlalala
Copy link
Contributor

I've configured project with the following command:
cmake.exe -G "MSYS Makefiles" -B build .
And then make gives me the following result:

$ make.exe 
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-internal.h:40,
                 from C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/gtest.h:62,
                 from c:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-all.cc:38:
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1959:10: error: '_stricmp' was not declared in this scope
   return _stricmp(s1, s2);
          ^~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1959:10: note: suggested alternative: 'strncmp'      
   return _stricmp(s1, s2);
          ^~~~~~~~
          strncmp
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1961:47: error: '_strdup' was not declared in this scope
 inline char* StrDup(const char* src) { return _strdup(src); }
                                               ^~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1961:47: note: suggested alternative: 'StrDup'       
 inline char* StrDup(const char* src) { return _strdup(src); }
                                               ^~~~~~~
                                               StrDup
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1969:40: error: '_fileno' was not declared in this scope
 inline int FileNo(FILE* file) { return _fileno(file); }
                                        ^~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:1969:40: note: suggested alternative: 'file'
 inline int FileNo(FILE* file) { return _fileno(file); }
                                        ^~~~~~~
                                        file
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:2027:56: error: 'fdopen' was not declared in this scope
 inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
                                                        ^~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/include/gtest/internal/gtest-port.h:2027:56: note: suggested alternative: 'fopen'        
 inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
                                                        ^~~~~~
                                                        fopen
In file included from c:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-all.cc:41:
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc: In static member function 'static bool testing::internal::String::CaseInsensitiveWideCStringEquals(const wchar_t*, const wchar_t*)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc:1942:10: error: '_wcsicmp' was not declared in this scope
   return _wcsicmp(lhs, rhs) == 0;
          ^~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc:1942:10: note: suggested alternative: 'wcsncmp'
   return _wcsicmp(lhs, rhs) == 0;
          ^~~~~~~~
          wcsncmp
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc: In member function 'int testing::UnitTest::Run()':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc:4921:21: error: '_OUT_TO_STDERR' was not declared in this scope
     _set_error_mode(_OUT_TO_STDERR);
                     ^~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc:4921:5: error: '_set_error_mode' was not declared in this scope
     _set_error_mode(_OUT_TO_STDERR);
     ^~~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest.cc:4921:5: note: suggested alternative: 'SetErrorMode'
     _set_error_mode(_OUT_TO_STDERR);
     ^~~~~~~~~~~~~~~
     SetErrorMode
In file included from c:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-all.cc:42:
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc: In function 'void testing::internal::DeathTestAbort(const string&)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:296:5: error: '_exit' was not declared in this scope
     _exit(1);
     ^~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:296:5: note: suggested alternative: '_Exit'
     _exit(1);
     ^~~~~
     _Exit
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual void testing::internal::DeathTestImpl::Abort(testing::internal::DeathTest::AbortReason)':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:527:3: error: '_exit' was not declared in this scope
   _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
   ^~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:527:3: note: suggested alternative: '_Exit'
   _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
   ^~~~~
   _Exit
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:771:24: error: '_MAX_PATH' was not declared in this scope        
   char executable_path[_MAX_PATH + 1];  // NOLINT
                        ^~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:771:24: note: suggested alternative: 'MAX_PATH'
   char executable_path[_MAX_PATH + 1];  // NOLINT
                        ^~~~~~~~~
                        MAX_PATH
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:773:65: error: 'executable_path' was not declared in this scope  
                                                                 executable_path,
                                                                 ^~~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'   
     if (!::testing::internal::IsTrue(expression)) { \
                                      ^~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:797:11: error: 'executable_path' was not declared in this scope  
           executable_path, const_cast<char*>(command_line.c_str()),
           ^~~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-death-test.cc:308:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'   
     if (!::testing::internal::IsTrue(expression)) { \
                                      ^~~~~~~~~~
In file included from c:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-all.cc:43:
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc: In static member function 'static testing::internal::FilePath testing::internal::FilePath::GetCurrentDir()':
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc:49:26: error: '_MAX_PATH' was not declared in this scope
 # define GTEST_PATH_MAX_ _MAX_PATH
                          ^~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc:101:12: note: in expansion of macro 'GTEST_PATH_MAX_'
   char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
            ^~~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc:49:26: note: suggested alternative: 'MAX_PATH'
 # define GTEST_PATH_MAX_ _MAX_PATH
                          ^~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc:101:12: note: in expansion of macro 'GTEST_PATH_MAX_'
   char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
            ^~~~~~~~~~~~~~~
C:/Users/ikravchu/Documents/Templates/Tests/googletest/googletest/src/gtest-filepath.cc:102:27: error: 'cwd' was not declared in this scope
   return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
                           ^~~
make[2]: *** [googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[1]: *** [googletest/CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2

I can bypass it by activation gcc extensions in the top level gtest CMakeLists.txt like this:
if(NOT CYGWIN) set(CMAKE_CXX_EXTENSIONS ON) message("Extensions: ${CMAKE_CXX_EXTENSIONS}") endif()

@piotrgrabowski2501
Copy link

Could you show your CMakeLists.txt, please? I add above extensions, but I still have the same errors like you.
image

@derekmauro derekmauro self-assigned this Aug 4, 2020
@Ogiwara-CostlierRain464
Copy link

Using MinGW64 instead of MinGW32 resolved the problem, in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants