Hello, I'm a developer with the MacPorts package management system. We've been asked to update our tdb package to version 1.3.1, and in the process of doing so, I've encountered some problem with your build process. tdb 1.3.1 builds its libtdb library without specifying the required "-install_name ..." flag. This results in programs that link with the library not being able to find the library after the build directory is removed. I am not familiar with the waf build system you use so I cannot suggest how to solve this in your build system, I can only tell you that you must add this flag. For example, if the library will ultimately be installed as /opt/local/lib/libtdb.1.dylib, then when building, in addition to the "-dynamiclib" flag that you already use, you must pass the flag "-install_name /opt/local/lib/libtdb.1.dylib".
Created attachment 10357 [details] Experimental patch for master Can someone test this patch?
I'll give it a whirl. We ran into the very same issue when trying to build Samba 4.1.12 with Macports, cf bug #10877.
Comment on attachment 10357 [details] Experimental patch for master Looks like ordering of the linkflags -install_name and -dynamiclib is important: if -install_name is used if must come *after* -dynamiclib, otherwise the linker gives an error I had to modify the patch to read + t.env.append_value('LINKFLAGS', '-dynamiclib -install_name') in order to pass at this point. Unfortunately it then fails at another point, cf my next post.
This is the error I see when applying the patch to the Samba 4.1.12 port I'm currently working on, assisting another Macports contributor in getting it to work. [ 5/4011] Linking default/lib/replace/libreplace.inst.dylib 10:51:17 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib' Afaict the install_name mustn't be set to the absolute path of the library, instead the leading path component that matches the passed rpath must be replaced by the literal string @rpath@, this would work: /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name @rpath@/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib Anyone with sufficient python and waf skills able to come up with a patch that does this?
I have only ever set "-install_name" to the absolute path the library will ultimately be installed into. I am not familiar with "-rpath" or "@rpath@". I do notice that "-dynamiclib" is being specified twice, which is at best redundant, and possibly problematic, I don't know.
(In reply to samba from comment #5) urks, your're right, looks like -install_name is supposed to work with absolute paths. I've done another attempt running the link command by hand and it works, alas the sambe command when executed from make fails: This is the error from Macports: # port -v install samba4 ... [ 5/4011] Linking default/lib/replace/libreplace.inst.dylib 11:31:51 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib' Waf: Leaving directory `/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin' ... # Lets run the build with make by hand: # cd "/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12" # /usr/bin/make -w install DESTDIR=/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/destroot ... [ 5/4011] Linking default/lib/replace/libreplace.inst.dylib 11:33:07 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib' Waf: Leaving directory `/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin' # Now lets take the actual clang command and run that by hand: # cd /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin # /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib # echo $? 0 # I'm at my wits end for the moment, sorry.
Created attachment 18294 [details] add -install_name to dylibs
I've attached a working patch (`-dynamiclib` is in `LINKFLAGS_cshlib` not `LINKFLAGS`). Please take a look.