2016-07-18 25 views
16

Mam nadzieję, że możesz mi pomóc. Napisałem mały projekt przy użyciu CxxTest na mojej głównej maszynie dev. Wszystko działa świetnie na tej maszynie, żadnych problemów. Próbowałem jednak skonfigurować ten projekt na moim nowym laptopie i po prostu nie mogę go uruchomić! Podejrzewam, że coś jest pomieszane z moją instalacją MinGW, a nie CxxTest, ale naprawdę trudno o tym wiedzieć - a błędy pochodzą z plików CxxTest. Jest to struktura folderów projektu:MinGW/CxxTest dziwne błędy

lib/ 
    cxxtest-4.3/ 
src/ 
    TestUtils.h 
    test.cpp 
test/ 
    MyTestSuite.h 
    libstdc++-6.dll 

W wierszu polecenia I run:

cd test 
..\lib\cxxtest-4.3\bin\cxxtestgen --error-printer -o runner.cpp MyTestSuite.h 

ten generuje runner.cpp. Teraz uruchamiam:

g++ -o runner.exe runner.cpp -I "../lib/cxxtest-4.3" -std=c++11 

Zwykle działa dobrze, wypuszczając runner.exe i uruchamiając moje testy jednostkowe. Na moim laptopie dostaję tysiące błędów. Oto tylko kilka pierwszych:

In file included from c:\mingw\include\wchar.h:208:0, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\cwchar:44, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\bits\postypes.h:40, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iosfwd:40, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ios:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\istream:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\sstream:38, 
       from c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\complex:45, 
       from ../lib/cxxtest-4.3/cxxtest/StdHeaders.h:24, 
       from ../lib/cxxtest-4.3/cxxtest/StdValueTraits.h:22, 
       from ../lib/cxxtest-4.3/cxxtest/ValueTraits.h:400, 
       from ../lib/cxxtest-4.3/cxxtest/TestSuite.h:24, 
       from ../lib/cxxtest-4.3/cxxtest/RealDescriptions.h:20, 
       from ../lib/cxxtest-4.3/cxxtest/TestRunner.h:22, 
       from runner.cpp:11: 
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_ino_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_mode_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_dev_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: '_off_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:173:14: error: 'time_t' does not name a type 
struct _stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_dev_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_ino_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_mode_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_dev_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: '_off_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:180:13: error: 'time_t' does not name a type 
struct stat __struct_stat_defined(_off_t, time_t); 
      ^
c:\mingw\include\sys/stat.h:188:17: error: '_dev_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_ino_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_mode_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '_dev_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: '__off64_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:188:17: error: 'time_t' does not name a type 
struct _stati64 __struct_stat_defined(__off64_t, time_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_dev_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_ino_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_mode_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '_dev_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__off64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 
       ^
c:\mingw\include\sys/stat.h:195:17: error: '__time64_t' does not name a type 
struct __stat64 __struct_stat_defined(__off64_t, __time64_t); 

Po uruchomieniu g ++ na prostym pliku hello world działa poprawnie. Czy ktoś wie, co się dzieje?

Odpowiedz

38

Niedawno zaktualizowałem MinGW i wpadłem na bardzo podobne problemy. Po pewnych badaniach znalazłem this question on SO i próbowałem zastąpić -std=c++11 przez -std=gnu++11. To rozwiązało problem dla mnie. Mam nadzieję, że pomaga!

+2

Lukas - dziękuję! To był rzeczywiście problem. Teraz widzę, że mam różne wersje MinGW na każdej maszynie, coś, co powinienem wziąć pod uwagę. – Draknir

+5

Miałem ten problem z CLion. Musiałem edytować CMakeLists.txt i zmienić -std = C++ 11 na -std = gnu ++ 11, jak wspomniałeś o Lukasie. Dziękuję Ci! – JDPeckham