如何获取CMake创建一个DLL及其匹配的lib文件? [英] How do I get CMake to create a dll and its matching lib file?
问题描述
我使用CMake通过Visual Studio 2010创建共享库。该解决方案输出一个dll文件,但不是一个匹配的lib文件。我如何告诉CMake生成lib文件,以便我可以链接其他项目到dll?
I'm using CMake to create a shared library via Visual Studio 2010. The solution outputs a dll file, but not a matching lib file. How do I tell CMake to generate the lib file so I can link other projects to the dll?
推荐答案
首先检查您的共享库中至少有一个导出的符号。如果dll不导出符号,Visual Studio不会生成 .lib
文件。
First of all check that you have at least one exported symbol in your shared library. Visual Studio does not generate the .lib
file if dll does not exports symbols.
接下来,检查您的cmake文件 - 可能您已设置共享库目标的 CMAKE_ARCHIVE_OUTPUT_DIRECTORY
变量或 ARCHIVE_OUTPUT_DIRECTORY
属性。如果这些变量/属性被设置,Visual Studio将输出 .lib
文件到该变量/属性指定的不同目录。 (还可以有配置特定的版本,如 ARCHIVE_OUTPUT_DIRECTORY_Release
。)
Next, check your cmake files - probably you have set CMAKE_ARCHIVE_OUTPUT_DIRECTORY
variable or ARCHIVE_OUTPUT_DIRECTORY
property of the shared library target. If these variable/property is set then Visual Studio will output .lib
files into the different directory specified by that variable/property. (There also can be configuration-specific versions like ARCHIVE_OUTPUT_DIRECTORY_Release
.)
这篇关于如何获取CMake创建一个DLL及其匹配的lib文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!