1

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 ?

Community
  • 1
  • 1
Barth
  • 14,295
  • 20
  • 67
  • 102
  • 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 Answers1

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
  • 342,876
  • 71
  • 713
  • 819