I've just built magic VLSI software on MacOs Sierra 10.12.2. This includes building tclmagic.dylib library. Now when testing Magic Exec I get:
magic
dyld: lazy symbol binding failed: Symbol not found: _HashInit
Referenced from: /usr/local/lib/magic/tcl/tclmagic.dylib
Expected in: flat namespace`
I searched and found the HashInit function inside an utility library which is included during linking:
gcc -g -I/usr/X11/include -I/Library/Frameworks/Tk.framework/Versions/8.6/Headers -I/Library/Frameworks/Tcl.framework/Versions/8.6/Headers -fno-common -Wimplicit-int -fPIC -I/Library/Frameworks/Tk.framework/Versions/8.6/Headers -I/Library/Frameworks/Tcl.framework/Versions/8.6/Headers -I. -I.. -o tclmagic.dylib -dynamiclib -flat_namespace -undefined suppress -noprebind \
../cmwind/libcmwind.o ../commands/libcommands.o ../database/libdatabase.o ../dbwind/libdbwind.o ../drc/libdrc.o ../debug/libdebug.o ../extract/libextract.o ../graphics/libgraphics.o ../select/libselect.o ../textio/libtextio.o ../tiles/libtiles.o ../windows/libwindows.o ../wiring/libwiring.o ../resis/libresis.o ../sim/libsim.o ../netmenu/libnetmenu.o ../plow/libplow.o ../utils/libutils.o ../ext2sim/libext2sim.o ../ext2spice/libext2spice.o ../calma/libcalma.o ../cif/libcif.o ../plot/libplot.o ../lef/liblef.o ../extflat/libextflat.o ../garouter/libgarouter.o ../mzrouter/libmzrouter.o ../router/librouter.o ../irouter/libirouter.o ../grouter/libgrouter.o ../gcr/libgcr.o ../tcltk/libtcltk.o -lc -lX11 -lGL -lGLU -lm -L/usr/X11/lib -lm
The HashInit function resides inside ../utils/libutils.o. I've also used nm -gU on the two binaries and the symbol is found:
nm -gU utils/libutils.o | grep HashInit
0000000000002880 T _HashInit
00000000000028c0 T _HashInitClient
nm -gU magic/tclmagic.dylib| grep HashInit
000000000011ec70 T _HashInit
000000000011ecb0 T _HashInitClient
I've now tried a separate linking command and dump out a symbol mapping file:
ld -o tclmagic.dylib -dylib -flat_namespace -undefined suppress -noprebind ../cmwind/libcmwind.o ../commands/libcommands.o ../database/libdatabase.o ../dbwind/libdbwind.o ../drc/libdrc.o ../debug/libdebug.o ../extract/libextract.o ../graphics/libgraphics.o ../select/libselect.o ../textio/libtextio.o ../tiles/libtiles.o ../windows/libwindows.o ../wiring/libwiring.o ../resis/libresis.o ../sim/libsim.o ../netmenu/libnetmenu.o ../plow/libplow.o ../utils/libutils.o ../ext2sim/libext2sim.o ../ext2spice/libext2spice.o ../calma/libcalma.o ../cif/libcif.o ../plot/libplot.o ../lef/liblef.o ../extflat/libextflat.o ../garouter/libgarouter.o ../mzrouter/libmzrouter.o ../router/librouter.o ../irouter/libirouter.o ../grouter/libgrouter.o ../gcr/libgcr.o ../tcltk/libtcltk.o -lc -lX11 -lGL -lGLU -lm -L/usr/X11/lib -lm -macosx_version_min 10.12 -all_load -why_load -map debug_map
ld: warning: option -noprebind is obsolete and being ignored
Again, I see the symbol is available:
cat debug_map | grep HashInit
0x0011F390 0x00000040 [ 18] _HashInit
0x0011F3D0 0x00000150 [ 18] _HashInitClient
0x001DADFE 0x00000006 [ 18] _HashInit
0x001DAE04 0x00000006 [ 18] _HashInitClient
0x001DF2B8 0x0000000A [ 18] _HashInit
0x001DF2C2 0x0000000A [ 18] _HashInitClient
0x0020C1D8 0x00000008 [ 18] _HashInit
0x0020C1E0 0x00000008 [ 18] _HashInitClient`
Btw, I've seen similar questions here and here, but I believe their scenario may be slightly different as one was cause by cmake mistake and the other was worked around by using DYLD_INSERT_LIBRARIES, which doesn't have an impact on my case.
Thanks in advance, Ronald