From octave-maintainers-request at bevo dot che dot wisc dot edu Tue Nov 26 07:46:36 2002 Subject: Shared libs on OSX From: Per Persson To: "John W. Eaton" Cc: octave-maintainers at bevo dot che dot wisc dot edu Date: Tue, 26 Nov 2002 14:50:04 +0100 --Apple-Mail-3--118137216 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hi, I've been looking into the issue of building shared libs for OS X and have made some progress. Some of the problems with dynamic linking (as reported before) persist, but I've been able to run a version octave built with shared libs. This was accomplished using a yet-to-be-released version of Apples gcc (v3.3 build 1301). One thing that will need to be changed in the Makefiles is with repect to the SH_LD and SH_LDFLAGS. In Mach-O objects there is a difference between a shared library (dylib) and a loadable module (.oct in this case). A dylib is used for linking either statically or shared from, but _not_ dynamically as opposed to ELF where I it is my understanding that a shared lib (.so) can be used for both shared and dynamic loading(?). Hence, I'd like to split SH_LD and SH_LDFLAGS into SH_LD, SH_LDFLAGS, DL_LD and DL_LDFLAGS where the default is DL_LD=SH_LD and DL_LDFLAGS=SH_LDFLAGS for systems other than OS X. I've attached a patch with the changes so you can comment on the suggestion. /Per --Apple-Mail-3--118137216 Content-Disposition: attachment; filename=osx_shared Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="osx_shared" Index: Makeconf.in =================================================================== RCS file: /cvs/octave/Makeconf.in,v retrieving revision 1.132 diff -u -d -b -w -U3 -w -r1.132 Makeconf.in --- Makeconf.in 2002/11/21 20:47:49 1.132 +++ Makeconf.in 2002/11/26 13:10:57 at @ -146,6 +146,9 @@ SH_LD = at SH_LD@ SH_LDFLAGS = at SH_LDFLAGS@ +DL_LD = at DL_LD@ +DL_LDFLAGS = at DL_LDFLAGS@ + SONAME_FLAGS = at SONAME_FLAGS@ RDYNAMIC_FLAG = at RDYNAMIC_FLAG@ Index: configure.in =================================================================== RCS file: /cvs/octave/configure.in,v retrieving revision 1.396 diff -u -d -b -w -U3 -w -r1.396 configure.in --- configure.in 2002/11/23 19:36:21 1.396 +++ configure.in 2002/11/26 13:10:57 at @ -629,6 +629,8 @@ SHLLINKEXT= SH_LD="$CXX" SH_LDFLAGS=-shared +DL_LD='$(SH_LD)' +DL_LDFLAGS='$(SH_LDFLAGS)' MKOCTFILE_SH_LDFLAGS='$(SH_LDFLAGS)' SONAME_FLAGS= RLD_FLAG= at @ -651,11 +653,16 @@ RLD_FLAG='-Xlinker -rpath -Xlinker $(octlibdir)' ;; *-*-darwin*) - SH_LDFLAGS='-bundle -bundle_loader $(TOPDIR)/src/octave' + DL_LDFLAGS='-bundle -bundle_loader $(TOPDIR)/src/octave' MKOCTFILE_SH_LDFLAGS='-bundle -bundle_loader $(bindir)/octave-$(version)$(EXEEXT)' + SH_LDFLAGS=-dynamiclib CXXPICFLAG= CPICFLAG= FPICFLAG= + SHLEXT=dylib + SHLLIB='$(SHLEXT)' + SHLEXT_VER='$(version).$(SHLEXT)' + SHLLIB_VER='$(version).$(SHLLIB)' INCLUDE_LINK_DEPS=true NO_OCT_FILE_STRIP=true ;; at @ -761,6 +768,8 @@ AC_MSG_RESULT([defining DLFCN_DIR to be $DLFCN_DIR]) AC_MSG_RESULT([defining SH_LD to be $SH_LD]) AC_MSG_RESULT([defining SH_LDFLAGS to be $SH_LDFLAGS]) +AC_MSG_RESULT([defining DL_LD to be $DL_LD]) +AC_MSG_RESULT([defining DL_LDFLAGS to be $DL_LDFLAGS]) AC_MSG_RESULT([defining MKOCTFILE_SH_LDFLAGS to be $MKOCTFILE_SH_LDFLAGS]) AC_MSG_RESULT([defining SONAME_FLAGS to be $SONAME_FLAGS]) AC_MSG_RESULT([defining NO_OCT_FILE_STRIP to be $NO_OCT_FILE_STRIP]) at @ -782,6 +791,8 @@ AC_SUBST(DLFCN_DIR) AC_SUBST(SH_LD) AC_SUBST(SH_LDFLAGS) +AC_SUBST(DL_LD) +AC_SUBST(DL_LDFLAGS) AC_SUBST(MKOCTFILE_SH_LDFLAGS) AC_SUBST(SONAME_FLAGS) AC_SUBST(NO_OCT_FILE_STRIP) Index: src/Makefile.in =================================================================== RCS file: /cvs/octave/src/Makefile.in,v retrieving revision 1.304 diff -u -d -b -w -U3 -w -r1.304 Makefile.in --- src/Makefile.in 2002/11/25 06:20:20 1.304 +++ src/Makefile.in 2002/11/26 13:10:58 at @ -32,10 +32,10 @@ ifeq ($(ENABLE_DYNAMIC_LINKING), true) ifdef CXXPICFLAG %.oct : pic/%.o octave$(EXEEXT) - $(SH_LD) $(SH_LDFLAGS) -o $ at $< $(OCT_LINK_DEPS) + $(DL_LD) $(DL_LDFLAGS) -o $ at $< $(OCT_LINK_DEPS) else %.oct : %.o octave$(EXEEXT) - $(SH_LD) $(SH_LDFLAGS) -o $ at $< $(OCT_LINK_DEPS) + $(DL_LD) $(DL_LDFLAGS) -o $ at $< $(OCT_LINK_DEPS) endif endif --Apple-Mail-3--118137216--