This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Loading cygwin dll's from non-cygwin applications (i.e., matlab)



Dear Cygwin Mailing List Participants:

Has anybody got _cygwin_ dynamic link libraries to execute
from within matlab (or any other non-cygwin application) ?

I've pretty much reviewed this mailing list to exhaustion
regarding getting a cygwin dll to run from matlab (i.e., a
"non-cygwin application").

It looked like a solution was in progress, but the conversation
stopped sometime in December.  I couldn't tell for sure
whether the conversation stopped because everybody gave up
or because a solution presented itself but didn't make
it to the mailing list (or anywhere else I could find).  I'm
guessing everybody gave up and pursued different avenues but
I really need to confirm this.  If this is the case, is there
any upcoming work that might solve the problem ?  Is it on
anybody's todo list ?

I saw the "--entry cygwin-noncygwin_dll_entry@12" which
made me think there was a solution - but to no avail - that
doesn't work.  I parred the code I stick into the dll down
to "main(){}", but no - it still doesn't run.  Matlab strips
its dll's of symbols, so debugging via gdb isn't going anywhere
I believe.  Maybe matlab can help me here - but I see nothing
regarding this in the technical archives on their web sites.

I used the information for mexing using cygwin from
http://www.physiol.ox.ac.uk/~mb3/gnumex20.html.  However,
those .bat's and mex.opts files, etc assume mingw32 (or whatever
the proper term for that is) and I changed that to use cygwin
with a small change to the .opts file.  Out of those scripts
I get my object file that I then feed into dlltool using
(among others) the cygwin_non_cygwin_dll_entry@12 entry point
provided for non-cygwin apps to enter the dll code.  The
above-mentioned url says you probably can't do what I'm trying
to do (I think "dangerous" was the term used) - but I'm forced
to try anyway.

My flags to dlltool match those provide by the java-ini example
provided by (excuse me if I'm wrong) Mumhit Kahn where he
explains how to build/use cygwin-compatible dynamic link libraries and the
flags used are pretty much exactly what is in the attached makefile
from that example.  I also used dlltool to create libraries (*.a's)
that, in-turn, call the matlab .dll's.  However, this isn't relevant for
the case where I stipped my code to just "main(){}".

Here's how I build exactly (/home/matlab is a cygwin link to //D/Matlabr11
aka d:\matlabr11 on my machine and loaddods.c is just "main(){}" at this
point)
----------------------------------------------------------------------------
--
BASH.EXE-2.02$ make loaddods
/home/matlab/bin/cmex.bat -c -g -DARCH_32BIT  -DHAVE_CONFIG_H -DUSE_LIBGXX_I
NLIN
ES -I. -I../../include -I/home/matlab/extern/include  -I/home/rmorris/data/b
uild
/DODS/packages-2.17/include -I/home/rmorris/data/build/DODS/packages-2.17/in
clud
e/w3c -I/usr/local/include loaddods.c
rm -rf loaddods.o
mv loaddods.obj loaddods.o
dllwrap --add-stdcall-alias -o loaddods.dll
loaddods.o -Wl,--entry,__cygwin_nonc
ygwin_dll_entry@12
Warning: no export definition file provided
dllwrap will create one, but may not be what you want
BASH.EXE-2.02$
----------------------------------------------------------------------------
---

Then I run this "loaddods.dll" from within matlab by cd'ng to the
appropriate
directory and

>> loaddods

The response by matlab is in the attached corel.jpg file.  That is,
the application crashes.

Porting the code to use mingw32 requires that each thing
I link with must also be ported (I believe) and it links
with a great deal - so this would be a very, very bad
time-consuming option (might as well have started out this
port of mine as a true "port", not one using UNIX emulation
via cygwin).  I must pursue getting it to work via the
cygwin unix emulation layer or choke and die trying :)

Can you shed light on my plight ?

Thank You !

Rob Morris
Jet Propulsion Laboratory












Makefile.nocyg

corel.jpg

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]