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 ?
Asked
Active
Viewed 552 times
1
-
Why not create a "shared" wrapper around your "static lib"? Of course, this all depends a bit on the usecase... – André Jan 18 '12 at 18:08
-
Possible duplicate of [CMake: How can I build a shared and a static library without recompiling the sources twice](http://stackoverflow.com/questions/12899582/cmake-how-can-i-build-a-shared-and-a-static-library-without-recompiling-the-sou) – Kamiccolo Dec 23 '15 at 18:12
1 Answers
2
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.

Fred Foo
- 355,277
- 75
- 744
- 836