[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dynamic loading in static exe
From: |
Paul Kienzle |
Subject: |
dynamic loading in static exe |
Date: |
Thu, 23 Jan 2003 16:56:22 -0500 |
User-agent: |
Mutt/1.2.5.1i |
All,
I've been playing with dynamic loading into statically
linked octave. The attached tarball demonstrates the
case of a dynamically loaded function calling back into
the main exe under mingw. I know similar things are
possible on IRIX, and I believe they are under Linux.
I don't know about OS/X.
The question is, do we want to support it? Is there
any advantage to static linking under Windows, other
than fewer files to work with?
Andy and I have noticed that oct-files are large even
when stripped, but we can get that benefit back for
pre-packaged oct-files by reintroducing
--disable-lite-kernel
or at least on windows, by clearing ENABLE_DYNAMIC_LINKING
even if --enable-shared.
Paul Kienzle
address@hidden
For archiving convenience, here is the Makefile:
%.o: %.c ; $(CC) $(CFLAGS) -c -o $@ $<
# objects included in the exe that
# dl objects can refer to.
OBJS=dynmain.o
# objects included in the exe that
# dl objects cannot refer to.
MAINOBJ=main.o
# dl objects
SO=dynsub.dll
# main program name
PROG=testdyn
all: $(SO) $(PROG).exe
dynsub.dll: dynsub.o lib$(PROG).a
gcc -shared -Wl,--export-all-symbols -Wl,--enable-auto-import dynsub.o
-o dynsub.dll -L. -l$(PROG)
$(PROG).def: $(OBJS)
# guess the export definitions from the objects
dlltool --export-all --output-def $(PROG).def $(OBJS)
lib$(PROG).a: $(PROG).def
# create the import symbols from the export definitions
dlltool --dllname $(PROG).exe --def $(PROG).def --output-lib
lib$(PROG).a
$(PROG).exe: $(MAINOBJ) lib$(PROG).a
# create the export symbols from the export definitions
dlltool --dllname $(PROG).exe --output-exp $(PROG).exp --def $(PROG).def
# create the exe, including the export symbols
gcc -o $(PROG).exe $(PROG).exp $(MAINOBJ) $(OBJS) -L. -l$(PROG)
clean:
rm -f *.{o,a,exe,dll,exp,def}
testdyn.tar.gz
Description: application/tar-gz
- dynamic loading in static exe,
Paul Kienzle <=