Re: [opendx-users] Building loadable modules under Mac OSX (Success !!)
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
Re: [opendx-users] Building loadable modules under Mac OSX
The short path here is because I am invoking dx from the command line, with: dx -mdf ./FancyRibbon.mdf I did also check to see if changing the LOADABLE line in the mdf file to the complete full path would make a difference. I get the same error message just with the complete path now instead of just a relative path, i.e. that DX cannot find the entry point DXEntry in the module. Still think that another linker switch is needed to make DXEntry the actual entry point for the module. Thanks, Norm I would say that the biggest problem probably lies within your mdf file. You should define the full path to the loadable module instead of a relative path ./FancyRibbon. David Hello DX'ers, I am attempting to get the FancyRibbon module compiled under Mac OSX. Up to this point, I have not been fully successful. After playing with the linker switches for a while, I can build the source successfully, but I get an error when DX tries to load the module. Has anyone successfully built a loadable module for OSX? Here are the details: OSX 10.2.8, Dec 2002 Developer Tools, VIS, Inc build of DX 4.3.0 I get the following error on load: 0: ERROR: MDF file: Invalid data: cannot find entry point 'DXEntry' in file './FancyRibbon' / module FancyRibbon I compiled the source with the following makefile : * DXARCH = macos BASE = /Applications/OpenDX/OpenDX.app/Contents/dx DXCC = cc INCLUDES = -I$(BASE)/include DXCFLAGS = -no-cpp-precomp -dynamic -Wall -I/usr/X11R6/include -fno-common -fPIC LINK = ld CHECK = -bundle_loader $(BASE)/bin_macos/dxexec LDFLAGS = -bundle -flat_namespace $(CHECK) -e _DXEntry LIBS = -L$(BASE)/lib_macos -L/sw/lib -lm -ldl FancyRibbon:FancyRibbon.c userFancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c FancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c userFancyRibbon.c $(LINK) $(LDFLAGS) $(LIBS) -o FancyRibbon userFancyRibbon.o FancyRibbon.o /usr/lib/bundle1.o rm FancyRibbon.o rm userFancyRibbon.o userFancyRibbon.c: FancyRibbon.mdf $(BASE)/bin/mdf2c -m FancyRibbon.mdf userFancyRibbon.c * The entry point is defined on the linker command line, but it does not appear to have stuck, making me think something else is wrong. It the underscore is omitted before DXEntry, the linker complains that it cannot find DXEntry. Any ideas as to what to change or try? Thanks, Norm -- . David L. Thompson Visualization and Imagery Solutions, Inc. mailto:[EMAIL PROTECTED]5515 Skyway Drive, Missoula, MT 59804 Phone : (406)756-7472 -- * Norman W. Schaeffler, Ph.D. Flow Physics and Control Branch NASA Langley Research Center Mail Stop 170, Building 1247A, Room 107 Hampton, Virginia 23681 Phone: (757) 864-5390 New E-Mail: [EMAIL PROTECTED]
Re: [opendx-users] Building loadable modules under Mac OSX
Norm, DX cannot find the entry point DXEntry in the module. Using gcc on Redhat Linux 9.0 and Fedora,the link for my loadable module has -e DXEntry while yours has -e _DXEntry. Is the additional underscore correct? Tjhe actual name of the routine is just DXEntry. Kent - - - Kent Eschenberg [EMAIL PROTECTED] (412)268-6829 Scientific Visualization Specialist, Pittsburgh Supercomputing Center There are 10 types of people in the world: those who understand binary, and those who don't.
Re: [opendx-users] Building loadable modules under Mac OSX
Which version of gcc are you using? You can look at the symbol table of your loadable module with nm and determine what symbols are in there. When I first was writing modules for MacOS X, the compiler used libtool for the linking and the compiler inserted the underscore (_) on all function names--that's why DXEntry became _DXEntry as the load symbol. Maybe that has now changed. David The short path here is because I am invoking dx from the command line, with: dx -mdf ./FancyRibbon.mdf I did also check to see if changing the LOADABLE line in the mdf file to the complete full path would make a difference. I get the same error message just with the complete path now instead of just a relative path, i.e. that DX cannot find the entry point DXEntry in the module. Still think that another linker switch is needed to make DXEntry the actual entry point for the module. Thanks, Norm -- . David L. Thompson Visualization and Imagery Solutions, Inc. mailto:[EMAIL PROTECTED]5515 Skyway Drive, Missoula, MT 59804 Phone : (406)756-7472
Re: [opendx-users] Building loadable modules under Mac OSX
I think the underscore in the symbol table is the problem. After looking at the dev-archives again, it seem that specifying an entry point is not even required in the current version, dx will always look for a DXEntry function in any module that it loads. The dev-archives pointed me to the file in the source that actually loads the module, loader.c. I took a look at that and, for my case, it seems like the module is opened, but the symbol DXEntry (without the underscore) is not found. So dx outputs the error message. I am using gcc 3.1. and there does not seem to be a way to get the compiler not add the leading underscore on function names in the symbol table. -fno-leading-underscore as a cc option does not appear to work. Based on the output of nm, all of the symbol names in dxexec have leading underscores too. So it seems that removing the underscores from the new module may not be the way to go. Unless I could remove it just from the DXEntry symbol. Thanks, Norm Which version of gcc are you using? You can look at the symbol table of your loadable module with nm and determine what symbols are in there. When I first was writing modules for MacOS X, the compiler used libtool for the linking and the compiler inserted the underscore (_) on all function names--that's why DXEntry became _DXEntry as the load symbol. Maybe that has now changed. David -- . David L. Thompson Visualization and Imagery Solutions, Inc. mailto:[EMAIL PROTECTED]5515 Skyway Drive, Missoula, MT 59804 Phone : (406)756-7472
Re: Re: [opendx-users] Building loadable modules under Mac OSX
Hmm. With a lot of hacking of the Makefile, I was able to compile the CMSP linux (12/99) package on my mac. I use the fink from dx, so there are minor variations. DX_ARCH= macos LIBDXL=$(BASE)/lib_$(DX_ARCH)/libDXL.a CFLAGS = -O -D$(DX_ARCH) -I$(BASE)/include -I/sw/include LIBS = -L$(BASE)/lib_macos -L/sw/lib -L/usr/X11R6/lib -L/usr/local/lib \ /usr/lib/bundle1.o -lpng -ltiff -lGL -lgcc -lX11 -ldl $(LIBDXL) #I'm missing -lnsl here, don't know if it's needed LDFLAGS = -read_only_relocs suppress -bundle -flat_namespace -undefined suppress -e _DXEntry Just a guess, but you appear to be missing $(LIBDXL). Jeremy PS. If it turns out that I've ported a obsolete version of the Chemistry modules, please provide me with a pointer to a more recent version. - In Response To - The short path here is because I am invoking dx from the command line, with: dx -mdf ./FancyRibbon.mdf I did also check to see if changing the LOADABLE line in the mdf file to the complete full path would make a difference. I get the same error message just with the complete path now instead of just a relative path, i.e. that DX cannot find the entry point DXEntry in the module. Still think that another linker switch is needed to make DXEntry the actual entry point for the module. Thanks, Norm I would say that the biggest problem probably lies within your mdf file. You should define the full path to the loadable module instead of a relative path ./FancyRibbon. David Hello DX'ers, I am attempting to get the FancyRibbon module compiled under Mac OSX. Up to this point, I have not been fully successful. After playing with the linker switches for a while, I can build the source successfully, but I get an error when DX tries to load the module. Has anyone successfully built a loadable module for OSX? Here are the details: OSX 10.2.8, Dec 2002 Developer Tools, VIS, Inc build of DX 4.3.0 I get the following error on load: 0: ERROR: MDF file: Invalid data: cannot find entry point 'DXEntry' in file './FancyRibbon' / module FancyRibbon I compiled the source with the following makefile : * DXARCH = macos BASE = /Applications/OpenDX/OpenDX.app/Contents/dx DXCC = cc INCLUDES = -I$(BASE)/include DXCFLAGS = -no-cpp-precomp -dynamic -Wall -I/usr/X11R6/include -fno-common -fPIC LINK = ld CHECK = -bundle_loader $(BASE)/bin_macos/dxexec LDFLAGS = -bundle -flat_namespace $(CHECK) -e _DXEntry LIBS = -L$(BASE)/lib_macos -L/sw/lib -lm -ldl FancyRibbon: FancyRibbon.c userFancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c FancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c userFancyRibbon.c $(LINK) $(LDFLAGS) $(LIBS) -o FancyRibbon userFancyRibbon.o FancyRibbon.o /usr/lib/bundle1.o rm FancyRibbon.o rm userFancyRibbon.o userFancyRibbon.c:FancyRibbon.mdf $(BASE)/bin/mdf2c -m FancyRibbon.mdf userFancyRibbon.c * The entry point is defined on the linker command line, but it does not appear to have stuck, making me think something else is wrong. It the underscore is omitted before DXEntry, the linker complains that it cannot find DXEntry. Any ideas as to what to change or try? Thanks, Norm -- . David L. Thompson Visualization and Imagery Solutions, Inc. mailto:[EMAIL PROTECTED]5515 Skyway Drive, Missoula, MT 59804 Phone : (406)756-7472 -- * Norman W. Schaeffler, Ph.D. Flow Physics and Control Branch NASA Langley Research Center Mail Stop 170, Building 1247A, Room 107 Hampton, Virginia 23681 Phone: (757) 864-5390 New E-Mail: [EMAIL PROTECTED]
Re: [opendx-users] Building loadable modules under Mac OSX
Hi Norm, My loadable has several parts so I start by compiliing each with gcc 3.3.2 and no -e. This produces a bunch of object files, extension .o. Using nm on these, I find the symbol DXEntry without the underscore in the appropriate file. Then, all the pieces are combined into a shared object, extension .so, using gcc with the options -shared -e DXEntry. I think gcc is actually just calling the loader ld. Again, nm finds the symbol 'DXEntry without the underscore in the output file. The man page for ld says that -e declares the place at which execution should begin. It also says that -shared is supported only on ELF, XCOFF and SunOS. Hope this helps. Kent --On Thursday, June 03, 2004 02:49:21 PM -0400 Norman W. Schaeffler [EMAIL PROTECTED] wrote: I think the underscore in the symbol table is the problem. After looking at the dev-archives again, it seem that specifying an entry point is not even required in the current version, dx will always look for a DXEntry function in any module that it loads. The dev-archives pointed me to the file in the source that actually loads the module, loader.c. I took a look at that and, for my case, it seems like the module is opened, but the symbol DXEntry (without the underscore) is not found. So dx outputs the error message. I am using gcc 3.1. and there does not seem to be a way to get the compiler not add the leading underscore on function names in the symbol table. -fno-leading-underscore as a cc option does not appear to work. Based on the output of nm, all of the symbol names in dxexec have leading underscores too. So it seems that removing the underscores from the new module may not be the way to go. Unless I could remove it just from the DXEntry symbol. Thanks, Norm
Re: [opendx-users] Building loadable modules under Mac OSX
I would say that the biggest problem probably lies within your mdf file. You should define the full path to the loadable module instead of a relative path ./FancyRibbon. David Hello DX'ers, I am attempting to get the FancyRibbon module compiled under Mac OSX. Up to this point, I have not been fully successful. After playing with the linker switches for a while, I can build the source successfully, but I get an error when DX tries to load the module. Has anyone successfully built a loadable module for OSX? Here are the details: OSX 10.2.8, Dec 2002 Developer Tools, VIS, Inc build of DX 4.3.0 I get the following error on load: 0: ERROR: MDF file: Invalid data: cannot find entry point 'DXEntry' in file './FancyRibbon' / module FancyRibbon I compiled the source with the following makefile : * DXARCH = macos BASE = /Applications/OpenDX/OpenDX.app/Contents/dx DXCC = cc INCLUDES = -I$(BASE)/include DXCFLAGS = -no-cpp-precomp -dynamic -Wall -I/usr/X11R6/include -fno-common -fPIC LINK = ld CHECK = -bundle_loader $(BASE)/bin_macos/dxexec LDFLAGS = -bundle -flat_namespace $(CHECK) -e _DXEntry LIBS = -L$(BASE)/lib_macos -L/sw/lib -lm -ldl FancyRibbon:FancyRibbon.c userFancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c FancyRibbon.c $(DXCC) $(INCLUDES) $(DXCFLAGS) -c userFancyRibbon.c $(LINK) $(LDFLAGS) $(LIBS) -o FancyRibbon userFancyRibbon.o FancyRibbon.o /usr/lib/bundle1.o rm FancyRibbon.o rm userFancyRibbon.o userFancyRibbon.c: FancyRibbon.mdf $(BASE)/bin/mdf2c -m FancyRibbon.mdf userFancyRibbon.c * The entry point is defined on the linker command line, but it does not appear to have stuck, making me think something else is wrong. It the underscore is omitted before DXEntry, the linker complains that it cannot find DXEntry. Any ideas as to what to change or try? Thanks, Norm -- . David L. Thompson Visualization and Imagery Solutions, Inc. mailto:[EMAIL PROTECTED]5515 Skyway Drive, Missoula, MT 59804 Phone : (406)756-7472