Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: From: "Willis, Matthew" To: "'Pavel Holejsovsky'" Cc: "'cygwin AT cygwin DOT com'" Subject: RE: Q. on creating DLL's for use w/ excel (export names without @ 0, @ 4 etc?) (cygwin 1.3.13-2) Date: Tue, 5 Nov 2002 09:59:13 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Thanks, I have everything working now, and have made loads of notes. I had to do everything with -mno-cygwin and this made linking against c++ libs a bit tricky (Solution: google for mingw-extras and install them). The reason I used -mno-cygwin is that I found excel was core dumping when I linked against cygwin1.dll; something about relocatable DLL conflicts. I suppose I should try to figure that out eventually, as well. This is how I ended up compiling a DLL that linked in some external routines from /usr/local/mylib/lib/libmylib_mingw.a # NB- The file foo.cpp has extern "C" linkage: # The -mdll part below may be redundant g++ -mno-cygwin -mdll foo.cpp -I/usr/local/mylib/include -c # Final linkage as follows: g++ -Wl,--kill-at --Wl,--out-implib,libfoo.import.a \ -mno-cygwin -shared -o foo.dll foo.o \ -L/usr/local/mylib/lib -lmylib_mingw \ -L/usr/local/mingw-extra/lib - Matt -----Original Message----- From: Pavel Holejsovsky [mailto:pavel DOT holejsovsky AT st DOT com] Sent: Tuesday, November 05, 2002 3:31 AM To: Matthew DOT Willis AT CIBC DOT ca Cc: cygwin AT cygwin DOT com Subject: Re: Q. on creating DLL's for use w/ excel (export names without @0, @ 4 etc?) (cygwin 1.3.13-2) Matthew, 1. you can try ld's option --kill-at. The link cmdline would look like this: gcc -Wl,--kill-at -Wl,--out-implib,libfoo.import.a -mno-cygwin -shared -o foo.dll foo.o 2. you can create .def file foo.def containing list of exported symbols without @NN suffix (one symbol per line). Then add .def file to your link commandline (be sure that it actually precedes all .o files). See ld docs for more details about both approaches. Pavel Matthew DOT Willis AT CIBC DOT ca wrote: > I've searched on google for some references to interfacing cygwin with > win32 > dll's. I've made a little progress but am kind of stuck creating DLL's > inside cygwin. The method I am using is the following: > > /* foo.c */ > #include > int WINAPI foobar() { return 1234; } > > gcc -mno-cygwin foo.c -c > gcc -Wl,--out-implib,libfoo.import.a -mno-cygwin -shared -o foo.dll foo.o > > When I look at the DLL file with MSVC's "depends.exe" I see the symbol is > "foobar AT 0" -- and I guess the @0 refers to how many bytes the function > args > take (I get @4 with a pointer to double, etc.). The only way I can > make the > symbols available to excel's visual basic interface is to cheat and > hexedit > foo.dll to change "foobar AT 0" to "foobarX0". Then I can put a few lines > in my > excel modules like > > Declare Function foobarX0 Lib "e:\dlltest\foo.dll" () As Integer > > Function MattVersion() > Dim i As Integer > i = foobarX0() > MattVersion = "MW 0.0.1.0.1." + Str(i) > End Function > > Surely there is a better way. Can anyone suggest a better technique? > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Bug reporting: http://cygwin.com/bugs.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/