EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026 Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
<== Date ==> <== Thread ==>

Subject: Re: STATIC_BUILD=YES for support module?
From: "Johnson, Andrew N. via Tech-talk" <tech-talk at aps.anl.gov>
To: David Bracey <dbracey at fnal.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 23 Feb 2026 22:27:15 +0000
Hi David,

There are 2 different static/shared switches in the EPICS build system, which have different effects.

When building a library, the setting SHARED_LIBRARIES=YES/NO tells the build whether to create a shared library or not. On Linux, setting it to YES to create a shared library (libXXX.so) also builds a static library (libXXX.a).

When building an executable or a shared library, the setting STATIC_BUILD=YES/NO tells the compiler & linker whether it may use shared libraries or not to resolve symbols at link-time. Setting it to YES should prevent linking to shared application libraries while creating that target. Some targets don’t support completely static builds though: MacOS doesn’t come with static versions of some of the system libraries for example, so static builds fail here; on Linux the system libraries are always linked shared.

If your IOC executable is built by a different Makefile than the one that builds the library, the IOC’s Makefile is the one that needs the STATIC_BUILD=YES setting. However if you only need to control whether a particular library you’re building will be linked statically or not, setting SHARED_LIBRARIES=NO when building that library will force all downstream linking of that library to use the static one without having to set STATIC_BUILD=YES in its Makefile — IOC executable builds can’t be linked to a shared library that doesn’t exist.

If you do try this, make sure that you’ve removed all copies of the shared library, because if both exist most linkers will use the shared one by preference. Running ‘make distclean’ in the application’s top directory will remove all those files.

You can find out what shared libraries an IOC executable was linked against with ‘ldd’. It won’t list static libraries at all.

HTH,

- Andrew


-- 

Complexity comes for free, Simplicity you have to work for.


On 2/23/26, 8:22 PM, "Tech-talk" <tech-talk-bounces at aps.anl.gov> wrote:

I added STATIC_BUILD=YES to my CONFIG_SITE for a support module, but the executable sizes did not change.

I was hoping to force the support module to statically link in another library that it needs, so that there would never be a run-time lib path problem.

Should I expect this to work, or is it an IOC-only option?


Replies:
Re: STATIC_BUILD=YES for support module? David Bracey via Tech-talk
References:
STATIC_BUILD=YES for support module? David Bracey via Tech-talk

Navigate by Date:
Prev: STATIC_BUILD=YES for support module? David Bracey via Tech-talk
Next: Re: STATIC_BUILD=YES for support module? David Bracey via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
Navigate by Thread:
Prev: STATIC_BUILD=YES for support module? David Bracey via Tech-talk
Next: Re: STATIC_BUILD=YES for support module? David Bracey via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  2025  <2026
ANJ, 19 Mar 2026 · Home · News · About · Talk · Base · Modules · Extensions ·
· Distributions · Download · Documents · Links · Licensing ·