From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18613 invoked from network); 2 Jun 2000 11:03:47 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 2 Jun 2000 11:03:47 -0000 Received: (qmail 23132 invoked by alias); 2 Jun 2000 11:03:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11724 Received: (qmail 23120 invoked from network); 2 Jun 2000 11:03:36 -0000 Date: Fri, 02 Jun 2000 12:03:05 +0100 From: Peter Stephenson Subject: Getting dynamic loading to work on cygwin To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FVI00DP2XD5AS@la-la.cambridgesiliconradio.com> Content-id: <16704.959943634.0@cambridgesiliconradio.com> MIME-version: 1.0 Content-type: MULTIPART/MIXED; BOUNDARY="Boundary_(ID_h4CCZgHQKfThuoBMDecLAg)" --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg) Content-id: <16704.959943634.1@cambridgesiliconradio.com> Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT In case anyone has a chance to play around with it, here's a minimal example of getting dynamically loaded libraries to work on cygwin. The changes to what we have already should be fairly mechanical but will still require a bit of work. Zefram's and Oliver's work on export files will come in handy, since it looks like cygwin will need a very similar set to AIX (there are tools to generate them automatically, but we have enough in place already to get it right). Just unpacking these and running make should create a main.exe and a dl.dll; running the first loads the second. I actually found out about the dllwrap incantation (which does all the hard work for you) from the perl dynamic loading configuration. There may be some issues about search paths still to resolve, since there are both .a (list of exports) and a .dll (the actual library) files; I haven't tried moving the files into different directories. It might also be more efficient to use dlltool directly rather than rely on dllwrap, but I for one don't have the patience. In case anyone is any doubt, this will *not* be in the release which is immediately due. --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg) Content-id: <16704.959943634.2@cambridgesiliconradio.com> Content-type: text/plain; charset=us-ascii; name=Makefile Content-description: Makefile Content-disposition: attachment; filename=Makefile Content-transfer-encoding: 7BIT .SUFFIXES: .so .dll CC = gcc CFLAGS = -O -g -Wall LIBS = # -ldl all: main dl.dll main: main.o $(CC) -o main main.o $(LIBS) dl.o: dl.c gcc $(CFLAGS) -c dl.c dl.dll : dl.o dllwrap --dllname $*.dll --driver-name gcc --dlltool dlltool --as as --def $*.def --output-lib lib$*.a dl.o dl.so : dl.o gcc -G -o dl.so dl.o clean: rm -f dl.o dl.so dl.dll main.o main libdl.a main.exe dl.base --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg) Content-id: <16704.959943634.3@cambridgesiliconradio.com> Content-type: text/plain; charset=us-ascii; name=main.c Content-description: main.c Content-disposition: attachment; filename=main.c Content-transfer-encoding: 7BIT #include #include int main(int argc, char **argv) { void *handle, *symbol; int ret; handle = dlopen("./dl.dll", RTLD_LAZY); if (handle == NULL) { fprintf(stderr, "dlopen failed.\n"); return 1; } symbol = dlsym(handle, "module"); if (symbol == NULL) { fprintf(stderr, "dlsym failed.\n"); return 1; } ret = ((int (*)(void))symbol)(); printf("module returned %d\n", ret); return 0; } --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg) Content-id: <16704.959943634.4@cambridgesiliconradio.com> Content-type: text/plain; charset=us-ascii; name=dl.c Content-description: dl.c Content-disposition: attachment; filename=dl.c Content-transfer-encoding: 7BIT #include int module(void) { printf("This is the module.\n"); return 42; } --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg) Content-id: <16704.959943634.5@cambridgesiliconradio.com> Content-type: text/plain; charset=us-ascii; name=dl.def Content-description: dl.def Content-disposition: attachment; filename=dl.def Content-transfer-encoding: 7BIT EXPORTS module --Boundary_(ID_h4CCZgHQKfThuoBMDecLAg)--