Experimental Physics and Industrial Control System
It should work fine to just set STATIC_BUILD=YES in the CONFIG_SITE file of your IOC application. I do this all the time.
The resulting binary will be linked statically against all of the EPICS libraries. However, it will still be linked dynamically against the system libraries. Here is an example of the ldd output for such an IOC application:
corvette:CARS/bin/linux-x86_64>ldd CARSApp
linux-vdso.so.1 => (0x00007ffe41ba1000)
libusb-0.1.so.4 => /lib64/libusb-0.1.so.4 (0x00007f81871e0000)
libuldaq.so.1 => /usr/local/lib/libuldaq.so.1 (0x00007f8186c67000)
libusb-1.0.so.0 => /lib64/libusb-1.0.so.0 (0x00007f8186a4e000)
libnet.so.1 => /lib64/libnet.so.1 (0x00007f8186834000)
libpcap.so.1 => /lib64/libpcap.so.1 (0x00007f81865f3000)
libboost_system.so.1.53.0 => /lib64/libboost_system.so.1.53.0 (0x00007f81863ef000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007f81860b1000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007f8185e9f000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8185c83000)
libreadline.so.6 => /lib64/libreadline.so.6 (0x00007f8185a3d000)
librt.so.1 => /lib64/librt.so.1 (0x00007f8185835000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f8185631000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f8185329000)
libm.so.6 => /lib64/libm.so.6 (0x00007f8185027000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8184e11000)
libc.so.6 => /lib64/libc.so.6 (0x00007f8184a43000)
libudev.so.1 => /lib64/libudev.so.1 (0x00007f818482d000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f8184605000)
/lib64/ld-linux-x86-64.so.2 (0x00007f81873e6000)
libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f81843db000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f81841d6000)
libdw.so.1 => /lib64/libdw.so.1 (0x00007f8183f85000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007f8183d81000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f8183b7c000)
libelf.so.1 => /lib64/libelf.so.1 (0x00007f8183964000)
libz.so.1 => /lib64/libz.so.1 (0x00007f818374e000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f8183528000)
libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f8183318000)
What do you see with ldd? Are you seeing it linked dynamically against the EPICS libraries, i.e. libca.so, libCom.so, etc.?
Mark
-----Original Message-----
From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Érico Nogueira Rolim via Tech-talk
Sent: Monday, October 17, 2022 1:08 PM
To: tech-talk at aps.anl.gov
Subject: Issues building statically linked IOC
Hi!
I'm developing an IOC to be deployed on a device running an older Linux distro, so I'm building the application statically in order to simplify my deployment process, at least until we can update the distro on the device. For this purpose, I'm starting out with epics base 3.15.9, which is giving me some issues.
- I added "STATIC_BUILD=YES" to my CONFIG_SITE file
- I ran "make" and the resulting binary was dynamic (per ldd output)
- I removed the contents of "STATIC_LDFLAGS_YES= -Wl,-Bstatic" and "STATIC_LDLIBS_YES= -Wl,-Bdynamic" in
configure/os/CONFIG.linux-x86.linux-x86 and the build was completed successfully but the resulting binary was still dynamic. Removing only the LDLIBS one lead to a linking error: "/usr/bin/ld: cannot find -lgcc_s"
- I changed "GNU_LDLIBS_YES = -lgcc" to "GNU_LDLIBS_YES = -lgcc -static"
in configure/CONFIG.gnuCommon
- I removed the contents of "STATIC_LDFLAGS_YES= -Wl,-Bstatic" and "STATIC_LDLIBS_YES= -Wl,-Bdynamic" in configure/os/CONFIG.Common.linuxCommon as well (the content from
CONFIG.linux-x86 seems to be partly duplicated)
- I added "COMMANDLINE_LIBRARY = READLINE_NCURSES" to CONFIG_SITE and changed "*LDLIBS_READLINE_NCURSES = -lreadline -lncurses" **to "*LDLIBS_READLINE_NCURSES = -lreadline -lncurses -ltinfo"* *in configure/os/CONFIG.Common.linuxCommon (in epics-base) to fix the linking errors due to missing functions from libtinfo (I feel like this should be handled by the build system, but I'm not sure how it would happen)
- the resulting binary was finally static
Did I miss something about building a static IOC? Having to mess around in the epics-base files doesn't seem ideal... To cover all my bases, I also tried doing this on epics-base 7.0.7, which required the same steps to spit out a static executable.
Thank you,
Érico
Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.
Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.
- Replies:
- Re: Issues building statically linked IOC Érico Nogueira Rolim via Tech-talk
- References:
- Issues building statically linked IOC Érico Nogueira Rolim via Tech-talk
- Navigate by Date:
- Prev:
RE: Streamdevice discards part of message Mark Rivers via Tech-talk
- Next:
Re: Streamdevice discards part of message Ralph Lange 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
- Navigate by Thread:
- Prev:
Re: Issues building statically linked IOC Michael Davidsaver via Tech-talk
- Next:
Re: Issues building statically linked IOC Érico Nogueira Rolim 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