On Windows it is possible to link directly to a DLL but this is more normally done through a stub-library.
> So on a native build on Windows the mpir.dll is accompanied by the stub >>>>> library mpir.lib. So an app links to the stub library which then links >>>>> to the DLL itself. IIRC a symbol 'sym' in the DLL becomes '__imp__sym' >>>>> in the stub library so it seems to me that the mingw/GCC build system >>>>> is >>>>> not producing a stub library. >>>>> >>>> >>>> That sounds right to me. The mingw build doesn't produce a .lib file >>>> (stub library). You have to create one if you want to use the dll produced >>>> by mingw. >>>> In fact, the stub library is apparently not required to use the dll >>>> with mingw, which I guess is why it doesn't create one. Internally, it >>>> uses >>>> the Microsoft linker, but I don't completely understand the precise >>>> mechanism. >>>> Bill. >>>> Brian >>>> >>> >> Ok I have tried building stub libraries (containing only one column with >> the names "__gmp_init" etc. of the functions used in the code, using the MS >> lib tool. Now using "-lmpir" or "-lmpir-16" in the mex command should find >> the libmpir-16.dll, which, I suppose, contains the addresses (locations) of >> the various function definitions, via the stub library? >> > > I guess that is the idea. Is your stub library named correctly now? > The stub library is now named "libmpir-16.lib" and, as it looks like, found when adding "-lmpir" to the mex compilation command. gcc works fine with "-lmpir" in MinGW and apparently uses "libmpir-16.dll" in .libs (because it fails if remove the latter). [So I understand gcc (and probably mex also) also look for "libmpir-xyz.lib", where xyz is an integer, when being passed "-lmpir"?] But is the stub library (and/or the .lib file) correct? Along Brian's post, for eg. the required function "mpf_init" should have a '__imp__mpf_init" entry in the stub library "libmpir-16.def" output dump. However, these exact entries are not there; what I can find is eg. "__gmpf_clear" and "__gmpf_init = ___gmpf_set_prec_raw". Is that the same as "__mpf_clear" and "__mpf_init"? Should the "= ___gmpf_set_prec_raw" part also be removed when editing the ".def" file to create a .lib file? What about three underscores versus two? The mex error also states with three underscores: "...unresolved external symbol __imp___gmpf_init in ...". It looks like the libmpir.dll does not contain the required format for the exported functions when I want to create a .lib file (via the MS lib tool) from it. Here is what "libmpir-16.def" contains after the dumpbin command "dumpbin /exports libmpir-16.dll > libmpir-16.def" in the DOS cmd (before removing the first columns containing addresses from it as described eg. here <http://asawicki.info/news_1420_generating_lib_file_for_dll_library.html>): -------- Selected contents of libmpir-16.def ------------------------------- Microsoft (R) COFF/PE Dumper Version 12.00.31101.0 Dump of file libmpir-16.dll File Type: DLL Section contains the following exports for libmpir-16.dll [...] 1 ordinal base 627 number of functions 627 number of names ordinal hint RVA name 1 0 00009430 __combine_limbs [...] 47 2E 00049050 __gmp_printf [...] 89 58 00003100 __gmpf_clear [...] 116 73 00004710 __gmpf_init = ___gmpf_set_prec_raw 117 74 00004750 __gmpf_init2 [...] 135 86 00005560 __gmpf_set = ___gmpf_set_ui [...] 139 8A 00005710 __gmpf_set_prec_raw [...] Summary 1000 .CRT 1000 .bss 1000 .data 5000 .edata D000 .eh_fram 1000 .idata 7000 .rdata 1000 .reloc 4F000 .text 1000 .tls -------------------------------- end selected content of "libmpir-16.def" -------------------------- -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com. To post to this group, send email to mpir-devel@googlegroups.com. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout.