Has anyone gotten runtime loadable modules to work on a Mac?
I have. With the help of people on this list, I worked through this
back in June. It should be in the archives, but in case it is not,
here is the summary message that closed the thread.
Cheers,
Norm
*******************************************
Hello DX's,
Thanks to all those who helped, specifically David Thompson who
provided the magic linker switch that created the correct symbol, I
now have a loadable version of the FancyRibbon module that "dx on
OSX" actually loads!
For anyone who is interested, below I have included the makefile that
I cobbled together. It may not be pretty, but it should allow you to
build a loadable module on your Mac. It is different from the example
makefiles included with dx in a couple of ways that I though I should
mention, in case anyone else is interested.
-bundle : A bundle is Apple's name for a dynamically loaded piece of
code, among other things. Loadable DX modules are built for OS X as
bundles. -flat_namespace is a bundle option.
-Wl,-iDXEntry:_DXEntry : This is the switch that creates the correct
symbol in the module that DX is looking for.
-bundle_loader $(BASE)/bin_macos/dxexec : This switch tells gcc that
dxexec is the executable that will be dynamically loading the code
you are compiling. This allows gcc to treat dxexec as if it were a
shared library for the purposes of resolving library functions. Most
of the other makefiles that I have seen for building bundles use
"-undefined suppress" instead. This causes the compiler to ignore ALL
unresolved externals. Depending on how many non-DX related libraries
you are using, -bundle_loader may be a better switch to use.
In the example makefiles, the last step is to call the linker, ld,
directly. Under OS X, it is cleaner to call gcc again and let it call
ld. Specifically it gets around the need to link to the
/usr/lib/bundle1.o object file manually. All of this is handled
automatically.
Cheers and thanks again for all the help,
Norm
********** Makefile *********
BASE = /Applications/OpenDX/OpenDX.app/Contents/dx
DXARCH = macos
DXCC = gcc
INCLUDES = -I$(BASE)/include
DXCFLAGS = -no-cpp-precomp -dynamic -Wall -fno-common -fPIC
CHECK = -bundle_loader $(BASE)/bin_macos/dxexec
LDFLAGS = -bundle -flat_namespace $(CHECK) -Wl,-iDXEntry:_DXEntry -e DXEntry
LIBS = -L$(BASE)/lib_macos -lm
FancyRibbon: FancyRibbon.c userFancyRibbon.c
$(DXCC) $(INCLUDES) $(DXCFLAGS) -c FancyRibbon.c
$(DXCC) $(INCLUDES) $(DXCFLAGS) -c userFancyRibbon.c
$(DXCC) $(LDFLAGS) $(LIBS) FancyRibbon.o userFancyRibbon.o -o
FancyRibbon
userFancyRibbon.c: FancyRibbon.mdf
$(BASE)/bin/mdf2c -m FancyRibbon.mdf >
userFancyRibbon.c