From: Marc C. <mar...@gm...> - 2021-04-12 16:31:18
|
Hi Kevan, Mach-O .dylib files can be used either as shared libraries or as link libraries. The LC_ID_DYLIB path is used *only* when you are linking an executable against the Tcl library, so as to make the executable use the Tcl library as a shared library. In that case the executable will acquire an LC_LOAD_DYLIB path which is the same as the LC_ID_DYLIB path in the Tcl library. To change the LC_ID_DYLIB path with install_name_tool you should use the -id option. The path that you provide as the value for that option will become the LC_ID_DYLIB path. But the otool -L command does *not* display the LC_ID_DYLIB path of a Mach file. It displays the LC_LOAD_DYLIB paths. And probably the LC_ID_DYLIB path is not your problem. You probably linked the main executable of your app against the Tcl library and you want it to dynamically load the Tcl library. So what you need to do is to change (or add) an LC_LOAD_DYLIB path in the main executable of your app so that it will do that. The LC_LOAD_DYLIB path that you want will probably look like @executable_path/../Frameworks/Tcl.framework/Versions/Current/Tcl. To do that with install_name_tool you need to use the -change option, not the -id option. I find it a pain to use otool and install_name_tool and that is why I wrote the utility "macher" which is much more to my taste and can do some things which are required by Tcl and Tk (now that they support zipfs singe-file-executables) and which are not available from Apple's tools. You can download macher from https://github.com/culler/macher/releases . - Marc On Sun, Apr 11, 2021 at 10:31 PM Kevan Hashemi <ha...@br...> wrote: > Greetings, > > I compiled the TclTk 8.7a3 embedded Wish shell on MacOS 10.12 (still > working on getting it to compile on my 10.15 machine). I am delighted with > its performance. I did encounter one obstacle. In the tcl.framework > directory we have: > > kevan@KSH5 8.7 % otool -L Tcl > Tcl: > /Library/Frameworks/Tcl.framework/Versions/8.7/Tcl (compatibility > version 8.7.0, current version 8.7.0) > <snip> > > This first line is the Mach-O LC_ID_DYLIB path. Compare to the same path > for an earlier version of TclTk: > > kevan@KSH5 8.6 % otool -L Tcl > Tcl: > @executable_path/../Frameworks/Tcl.framework/Versions/8.6/Tcl > (compatibility version 8.6.0, current version 8.6.10) > <snip> > > Suppose our embedded Wish shell loads a dynamic library X.dylib. In order > for X.dylib to install commands into the Tcl interpreter, it must have > previously been compiled and linked to the Tcl framework. When Wish loads > X.dylib with the "load" command, it tries to make sure that all libraries > that X.dylib depends upon are also loaded. So Wish will look for the > dependent Tcl library in the LC_ID_DYLIB path provided by the Tcl library > when X.dylib was created. In the case of Tcl 8.7, LC_ID_DYLIB points to a > non-existent library. In the case of 8.6, LC_ID_DYLIB provids a relative > path that locates the same Tcl library used by the Wish shell itself. > > I have been unable to change LC_ID_DYLIB in the Tcl library with > install_name_tool, but we can change the path to the Tcl library that is > recorded in X.dylib, like this: > > install_name_tool -change \ > /Library/Frameworks/Tcl.framework/Versions/8.7/Tcl \ > @executable_path/../Frameworks/Tcl.framework/Versions/8.7/Tcl \ > X.dylib > > Now Wish can load X.dylib. Meanwhile, the Tk 8.7 library does not have > this problem: it provides the traditional relative path for LD_ID_DYLIB. > > So, I have a fix, which I have automated in my Makefile, but I'm wondering > if this is something that should be set right in the configure script. > > Best, Kevan > > -- > Kevan Hashemi, Electrical Engineer > Physics Department, Brandeis University > http://www.bndhep.net > > > _______________________________________________ > Tcl-mac mailing list > tc...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-mac > |