public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* An issue with Matlab for a mex file compiled with GNU CYGWIN g++
@ 2013-07-01  2:27 Emad Gad
  2013-07-01  4:35 ` David Billinghurst
  2013-07-01 11:23 ` Tim Prince
  0 siblings, 2 replies; 5+ messages in thread
From: Emad Gad @ 2013-07-01  2:27 UTC (permalink / raw)
  To: cygwin

Hello

I apologize that this message is a long one. But you may skip to the
question at the end, if you wish to know the troubles I am having.

I have been using LINUX for a very long time.
I decided to compile my work on CYGWIN. Furthermore, I wanted to compile a
Matlab interface to be able to use it from Matlab under Windows.

I succeeded, after plodding for a whole weekend, in compiling everything,
without errors.

The problem came when I tried to run the matlab interface, which is the
usual .mexw64 (on the recent versions of Matlab) file that is produced by
the mex uttility in Matlab. At that moment, Matlab complained of “Invalid
mex file: [the file name].mexw64 is not a valid Win32 application”

I know that, up until now, the problem does not seem even remotely related
to CYGWIN.

However, investigating and reading around the web about this issue further
has led me to conclude that Matlab will generate this error if the .mexw64
the dll in question refers or uses other 32 bit dll. Matlab presumably
cannot run a hybrid dll, that is a dll with 64 and 32 bits components.

I then used the “Dependency Walker” tool to examine the components of my
.mexw64. And I found out that my “.mexw64” file is linked to the following
library C:\Windows\system32\kernel32.dll, which is a flagrantly 32 bit
Windows system dll. So I assumed that this must be the reason that Matlab
failed to run the mex file, and wanted to know why this library got linked
in the first place.

That brings me to the CYGWIN connection: The CYGWIN linker that I invoked to
finish the job is the g++-4, which has added the library kernel32.dll, with
the linker flag –lkernel32.dll. Notice that this linker flag has been aded
by the linker, and not by me. It also added the 32-bit Windows path on the
Library paths, and that is how I ended up putting a 32-bit dll in the
structure of 64 bit mex file.

And that finally brings me to the main point of my post, and my question.

Is there a way to make the CYGWIN g++ linker choose the Windows 64 bit
system libraries instead of the 32 bit?





--
View this message in context: http://cygwin.1069669.n5.nabble.com/An-issue-with-Matlab-for-a-mex-file-compiled-with-GNU-CYGWIN-g-tp100307.html
Sent from the Cygwin list mailing list archive at Nabble.com.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-12  7:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-01  2:27 An issue with Matlab for a mex file compiled with GNU CYGWIN g++ Emad Gad
2013-07-01  4:35 ` David Billinghurst
2013-07-01 11:23 ` Tim Prince
2013-07-12  4:51   ` Emad Gad
2013-07-12  8:28     ` Csaba Raduly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).