Experimental Physics and Industrial Control System
Hello folks,
Today I found that some Linux (cross) architectures (using gcc 4.4.2, 4.7.2) require an additional linker flag: -Wl,-rpath-link in addition to -L and -Wl,-rpath. I noticed when compiling asyn.
It worked for me to change in <BASE>/configure/os/CONFIG.Common.linuxCommon
PRODDIR_RPATH_LDFLAGS_YES = $(PROD_DEPLIB_DIRS:%=-Wl,-rpath,%)
to
PRODDIR_RPATH_LDFLAGS_YES = $(PROD_DEPLIB_DIRS:%=-Wl,-rpath,%) $(PROD_DEPLIB_DIRS:%=-Wl,-rpath-link,%)
(Maybe the same should be done for SHRLIBDIR_RPATH_LDFLAGS_YES.)
Why this? Some linkers do not use -L for indirectly linked libs. E.g. libA.so depends on libB.so and the program is linked with -lA but not with -lB, then some linkers require that B is found in -rpath-link and do not consider -L or -rpath for it. (Maybe the other linkers where it works do not even care about B?)
In asyn this is the case for test code which links with -lasyn -lCom only. But libasyn.so had been linked with -ldbRecStd -ldbCore -lca -lCom and the linker refuses to use those other libraries from -L<EPICS_BASE_LIBDIR> or -Wl,-rpath<EPICS_BASE_LIBDIR>.
/opt/eldk-5.3/powerpc-4xx/sysroots/i686-eldk-linux/usr/bin/ppc440e-linux/powerpc-linux-g++ -D_GNU_SOURCE -D_DEFAULT_SOURCE -m32 -mcpu=440fp -mhard-float --sysroot=/opt/eldk-5.3/powerpc-4xx/sysroots/ppc440e-linux -DUNIX -Dlinux -fno-strict-aliasing -O3 -g -g -Wall -I. -I../O.Common -I. -I. -I.. -I../../../../include/compiler/gcc -I../../../../include/os/Linux -I../../../../include -I/usr/local/epics/base-7.0.4.1/include/compiler/gcc -I/usr/local/epics/base-7.0.4.1/include/os/Linux -I/usr/local/epics/base-7.0.4.1/include -c ../asynPortDriverTest.cpp
/opt/eldk-5.3/powerpc-4xx/sysroots/i686-eldk-linux/usr/bin/ppc440e-linux/powerpc-linux-g++ -o asynPortDriverTest -L/afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP -L/usr/local/epics/base-7.0.4.1/lib/eldk53-ppc4xxFP -Wl,-rpath,/afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP -Wl,-rpath,/usr/local/epics/base-7.0.4.1/lib/eldk53-ppc4xxFP --sysroot=/opt/eldk-5.3/powerpc-4xx/sysroots/ppc440e-linux -rdynamic asynPortDriverTest.o -lasyn -lCom
/net/gfa-fs-4/export/cross_tools/eldk-5.3/powerpc-4xx/sysroots/i686-eldk-linux/usr/bin/ppc440e-linux/../../libexec/ppc440e-linux/gcc/powerpc-linux/4.7.2/ld: warning: libdbRecStd.so, needed by /afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP/libasyn.so, not found (try using -rpath or -rpath-link)
/net/gfa-fs-4/export/cross_tools/eldk-5.3/powerpc-4xx/sysroots/i686-eldk-linux/usr/bin/ppc440e-linux/../../libexec/ppc440e-linux/gcc/powerpc-linux/4.7.2/ld: warning: libdbCore.so, needed by /afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP/libasyn.so, not found (try using -rpath or -rpath-link)
/net/gfa-fs-4/export/cross_tools/eldk-5.3/powerpc-4xx/sysroots/i686-eldk-linux/usr/bin/ppc440e-linux/../../libexec/ppc440e-linux/gcc/powerpc-linux/4.7.2/ld: warning: libca.so, needed by /afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP/libasyn.so, not found (try using -rpath or -rpath-link)
/afs/psi.ch/group/8211/dirk/git/DRV/asyn/lib/eldk53-ppc4xxFP/libasyn.so: undefined reference to `scanIoRequest'
[... more undefined reference errors...]
Even though the warning suggests using -rpath or -rpath-link, only -rpath-link actually does the job.
Is there any (old) Linux architecture where adding -rpath-link may cause problems?
Dirk
- Replies:
- Re: EPICS linker problem Mark Rivers via Core-talk
- Re: EPICS linker problem Michael Davidsaver via Core-talk
- Navigate by Date:
- Prev:
Build completed: EPICS Base 7 base-7.0-50 AppVeyor via Core-talk
- Next:
Re: EPICS linker problem Mark Rivers via Core-talk
- Index:
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:
Build completed: EPICS Base 7 base-7.0-50 AppVeyor via Core-talk
- Next:
Re: EPICS linker problem Mark Rivers via Core-talk
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
<2020>
2021
2022
2023
2024