Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

--enable-static vs --disable-shared

Tags:

libraries

I understand the importance of shared vs static libraries. However, several programs I have come across recommend compiling with

--enable-static

while other recommend

--disable-shared

Are these the same thing? And if not, what is the difference?

If possible, please give an example of when to use one as opposed to the other.

like image 205
bremen_matt Avatar asked Apr 09 '18 12:04

bremen_matt


1 Answers

In the common case that these are switches to a "configure" script generated by Autoconf and Libtool, then they officially mean closely-related, but different, things. --enable-static means do build static libraries; --disable-shared means don't build shared libraries.

If you want to be sure to get only static libraries, no matter what, you need to give both options. However, often just --disable-shared will have that effect, because think about the possibilities: if the package builds only static libraries by default, then --disable-shared is a no-op; if it builds both static and shared libraries by default, then you just have to turn off the shared libraries to get what you want; and if it builds only shared libraries by default, then you might think you need both options, but if you just say --disable-shared, Libtool will usually notice that it's now being asked to build nothing, assume that that couldn't possibly be what you wanted, and flip the --enable-static switch for you.

like image 128
zwol Avatar answered Nov 12 '22 10:11

zwol