用Visual Studio创建gtest动态链接库工程 Step1 创建名为gtest的Win32 Project Step2 在Application Settings中的Application type下选择DLL Step4 设置gtest的代码路径 Step5 设置gtest动态链接库需要的Preprocessor Definitions Step6 关闭gtest-all.cc的Precompiled header

用Visual Studio创建gtest动态链接库工程
Step1 创建名为gtest的Win32 Project
Step2 在Application Settings中的Application type下选择DLL
Step4 设置gtest的代码路径
Step5 设置gtest动态链接库需要的Preprocessor Definitions
Step6 关闭gtest-all.cc的Precompiled header

Step2 在Application Settings中的Application type下选择DLL

用Visual Studio创建gtest动态链接库工程
Step1 创建名为gtest的Win32 Project
Step2 在Application Settings中的Application type下选择DLL
Step4 设置gtest的代码路径
Step5 设置gtest动态链接库需要的Preprocessor Definitions
Step6 关闭gtest-all.cc的Precompiled header

Step3 把gtest-all.cc加入到工程

用Visual Studio创建gtest动态链接库工程
Step1 创建名为gtest的Win32 Project
Step2 在Application Settings中的Application type下选择DLL
Step4 设置gtest的代码路径
Step5 设置gtest动态链接库需要的Preprocessor Definitions
Step6 关闭gtest-all.cc的Precompiled header

Step4 设置gtest的代码路径

左侧目录树选择“Configuration Properties > C/C++ > General”,在右侧“Additional Include Directories”中添加Include路径,分别指向gtest的根目录和include目录:

用Visual Studio创建gtest动态链接库工程
Step1 创建名为gtest的Win32 Project
Step2 在Application Settings中的Application type下选择DLL
Step4 设置gtest的代码路径
Step5 设置gtest动态链接库需要的Preprocessor Definitions
Step6 关闭gtest-all.cc的Precompiled header

Step5 设置gtest动态链接库需要的Preprocessor Definitions

左侧目录树选择“Configuration Properties > C/C++ > Preprocessor”,在右侧“Preprocessor Definitions”中将向导生成的宏定义“GTEST_EXPORTS”替换成“GTEST_CREATE_SHARED_LIBRARY”。

Step6 关闭gtest-all.cc的Precompiled header

注意这里修改的是单个文件的Properties,不是整个工程的Properties。左侧目录树选择“Configuration Properties > C/C++ > Precompiled Headers“,在右侧“ Precompiled Header”中选择“Not Using Precompiled Headers”。

用Visual Studio创建gtest动态链接库工程
Step1 创建名为gtest的Win32 Project
Step2 在Application Settings中的Application type下选择DLL
Step4 设置gtest的代码路径
Step5 设置gtest动态链接库需要的Preprocessor Definitions
Step6 关闭gtest-all.cc的Precompiled header

编译工程即可得到gtest动态链接库。


系列文章索引:http://www.cnblogs.com/duxiuxing/p/4270836.html