1、googletest
下载源码:https://github.com/google/googletest
安装32位库
sudo apt install gcc-multilib g++-multilib
编译
mkdir build & cd build
cmake -DCMAKE_CXX_FLAGS=-m32 ..
make
拷贝库文件,该库文件是32位编译,在64位系统下需注意
将lib下的静态库文件copy到/usr/lib目录下
2、拷贝头文件
1)拷贝gmock文件夹到/usr/include目录下
2)拷贝gtest文件夹到/usr/include目录下
3、编译mockcpp
下载源码:https://code.google.com/archive/p/mockcpp/downloads
安装python2库
sudo apt install python2.7
创建连接文件
ln -s python2.7 python
编译
mkdir build & cd build
cmake -DCMAKE_CXX_FLAGS=-m32 ..
make
最终会生成bulid/src/libmockcpp.a,拷贝到/usr/lib下
可能会报错
/root/work/soft/mockcpp/include/mockcpp/mockcpp.h:59:8: error: expected identifier before ‘static_assert’
59 | struct static_assert
| ^~~~~~~~~~~~~
/root/work/soft/mockcpp/include/mockcpp/mockcpp.h:59:8: error: expected unqualified-id before ‘static_assert’
make[2]: *** [src/CMakeFiles/mockcpp.dir/build.make:82: src/CMakeFiles/mockcpp.dir/AfterMatcher.cpp.o] Error 1
修改
#if __cplusplus < 199711L
template <bool condition>
struct static_assert
{
typedef int static_assert_failure[condition ? 1 : -1];
};
#endif
可能还需要安装:sudo apt-get install libboost-dev
4、拷贝mockcpp头文件
cp mockcpp /usr/lib -a
5、已编译好,可直接下载源码和库文件
https://download.csdn.net/download/niu_88/50543285
|