[英]Build gtest as shared library (dll) in CMake
I have never worked with CMake before, so please forgive any rookie mistakes. CMake我之前没有接触过,菜鸟犯错请见谅。 Most of the following working frame has been given to me by my project group.
以下大部分工作框架都是我的项目组给我的。 The goal is to build GoogleTest into a.dll, to be used in different, indepentent parts of our project.
目标是将 GoogleTest 构建成 a.dll,以用于我们项目的不同、独立的部分。 I'm having troubles setting up CMake the right way.
我无法以正确的方式设置 CMake。
The work-flow so far has been:到目前为止的工作流程是:
CMakeCache.txt
to have it produce a Code::Blocks project fileCMakeCache.txt
中的变量,让它生成一个 Code::Blocks 项目文件So far, it produces a static library (.a files) that can be used in our project.至此,生成了一个static的库(.a文件),可以在我们的项目中使用。 I'm having troubles genereating.dll files.
我在生成 .dll 文件时遇到问题。 Variables I have tried changing:
我尝试更改的变量:
BUILD_SHARED_LIBS:BOOL=ON
--> the files generated by Code::Blocks now have a.dll.a double extension BUILD_SHARED_LIBS:BOOL=ON
--> Code::Blocks 生成的文件现在有一个.dll.a 双扩展名CMAKE_C_FLAGS
and all the corresponding C++ flags where set to -DGTEST_CREATE_SHARED_LIBRARY=1
as given here CMAKE_C_FLAGS
和所有相应的 C++ 标志设置为-DGTEST_CREATE_SHARED_LIBRARY=1
如此处给出CMAKE_EXE_LINKER_FLAGS
has been set to -shared
to make the linker produce.dll files CMAKE_EXE_LINKER_FLAGS
已设置为 -shared 以使-shared
产生 .dll 文件I have worked my way through the GoogleTest documentation here and here but in both, building it into a.dll is merely a 2-sentence-topic.我已经在此处和此处浏览了 GoogleTest 文档,但在这两个文档中,将其构建到 a.dll 中只是一个两句主题。
As @Tsyvarev pointed out, the .dll
files were created in a (very) different folder.正如@Tsyvarev 指出的那样,
.dll
文件是在一个(非常)不同的文件夹中创建的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.