如何在不使用CMake重新编译源代码的情况下构建共享库和静态库 [英] How to build a shared and a static library without recompiling the sources with CMake
本文介绍了如何在不使用CMake重新编译源代码的情况下构建共享库和静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想构建与该库相同的静态版本和共享版本,如。但是,源代码被编译了两次,每个版本一个都没有必要。
避免这种情况的任何方法?
I want to build both a static and shared version of the same library as described here. However, the sources are compiled twice, one for each version which is not necessary. Any ways of avoiding this ?
推荐答案
取决于平台。至少在Linux上,您需要使用不同的编译器标志来生成与位置无关 (共享库)比普通(程序或静态库)代码。
Depends on the platform. On Linux at least, you need to use different compiler flags to produce position-independent (shared library) than ordinary (program or static library) code.
这篇关于如何在不使用CMake重新编译源代码的情况下构建共享库和静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文