From a1efa7857ec53b5c953897c56ecd60489e093e72 Mon Sep 17 00:00:00 2001 From: ighvh <115996604+ighvh@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:47:23 +0200 Subject: [PATCH] Fix linking against libraries in Makefile.modinc When linking a shared object/executable, libraries have to be added after the object files and not before. Otherwise, symbols used in the object files are not resolved. See https://forum.linuxcnc.org/9-installing-linuxcnc/41983-linuxcnc-ethercat-undefined-symbol-ecrt-slave-config-sdo?start=0 --- src/Makefile.modinc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.modinc.in b/src/Makefile.modinc.in index 35c0da04aeb..e042a81bf66 100644 --- a/src/Makefile.modinc.in +++ b/src/Makefile.modinc.in @@ -122,7 +122,7 @@ $(foreach mod,$(patsubst %.o,%,$(obj-m)),\ $(Q)ld -d -r -o $*.tmp $^ $(Q)objcopy -j .rtapi_export -O binary $*.tmp $*.sym $(Q)(echo '{ global : '; tr -s '\0' < $*.sym | xargs -r0 printf '%s;\n' | grep .; echo 'local : * ; };') > $*.ver - $(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -Wl,--version-script,$*.ver -o $@ $^ -lm + $(Q)$(CC) -shared -Bsymbolic $(LDFLAGS) -Wl,--version-script,$*.ver -o $@ $^ -lm $(EXTRA_LDFLAGS) $(Q)chmod -x $@ endif