Can I compile 64-bit MEX-files in MATLAB that access functions in 32-bit DLL's?

5 views (last 30 days)
I am running 64-bit MATLAB on 64-bit Windows. I saw in the release notes that dynamically linked libraries are only supported in 32-bit environments.
I want to know whether this means that I can no longer link my 64-bit MEX code with 32-bit DLL functions, even though Matlab is not directly calling the DLL's function. I receive the following error when I attempt to perform this
??? Invalid MEX-file 'foo.mexw64':
z:\...\foo.mexw64 is not a valid Win32 application.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to compile 64-bit MEX-files that access functions in 32-bit DLL's is not available in MATLAB. 64-bit applications such as 64-bit MATLAB can only use 64-bit shared libraries. In general, you cannot mix 32-bit and 64-bit code in a single application. If you have a 64-bit application, everything related to that application, including the DLLs, must be compiled as 64-bit.
To work around this issue, any DLLs called by your code also need to be compiled in 64-bit (everything down to math libraries called, if any). Violating this restriction does not cause an error at the compilation or link stages, but the resulting MEX file cannot be loaded. If you recompile your various DLLs as 64-bit shared libraries, you can then build a pure 64-bit MEX file. This may involve modifying the source code for those DLLs to account for the change from 32-bit to 64-bit integers.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!