codeblock 编译googletest

1、cmake安装

2、codeblock  16.01 

3、Google Test 1.7.0

4、PATH路径添加(重启电脑,保证设置的PATH路径生效)

5、python安装

6、编译安装:  http://www.cnblogs.com/TenosDoIt/p/3412721.html

错误:

||=== Build: Debug in d (compiler: GNU GCC Compiler) ===|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h||In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h|1719|error: '_stricmp' was not declared in this scope|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h||In function 'char* testing::internal::posix::StrDup(const char*)':|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h|1721|error: '_strdup' was not declared in this scope|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h||In function 'int testing::internal::posix::FileNo(FILE*)':|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h|1729|error: '_fileno' was not declared in this scope|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h||In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h|1779|error: 'fdopen' was not declared in this scope|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

解决: 在codeblocks上的build-options上去除-std=C++11 ,添加-std=gnu++

错误:

||=== Build: all in gtest (compiler: GNU GCC Compiler) ===|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h||In function 'void testing::internal::SleepMilliseconds(int)':|
D:sourcegoogletest-release-1.7.0includegtestinternalgtest-port.h|1193|error: 'nanosleep' was not declared in this scope|
D:sourcegoogletest-release-1.7.0srcgtest-death-test.cc|123|warning: 'testing::internal::g_in_fast_death_test_child' defined but not used [-Wunused-variable]|
CMakeFilesgtest.diruild.make|62|recipe for target 'CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed|
CMakeFilesMakefile2|66|recipe for target 'CMakeFiles/gtest.dir/all' failed|
D:sourcegoogletest-release-1.7.0codeblocks-mingwMakefile|82|recipe for target 'all' failed|
||=== Build failed: 4 error(s), 1 warning(s) (0 minute(s), 1 second(s)) ===|

解决:注释  nanosleep 这一行

编译Google Test 1.8.0,出现很多编译错误,有可能是Mingw版本过老

原文地址:https://www.cnblogs.com/hzijone/p/5926014.html