

With a bunch of patience, I finally gathered all pieces that solves this problem and now I can just specify the architecture when calling mex, and the right outcome is expected. Some library files for building a 32-bit mex file do not exist in 64-bit installation and have to be copied from a 32-bit version. Pieces of code here and there from Mathworks are not that friendly to the idea of cross-platform compiling. The architecture switch in mex command simply does not work as intended.

During the last week I have bin doing several attempts to make the unsuportet (by Matlab at least) link between PGI and MATLAB work. After reading a few post online, I figured that there is no short-cut solution for this problem. Background: I have some Matlab functions that I have implemented in C++ for my Master Thesis, and I want to try using the PGI 14.1 compiler with OpenACC to GPU-accelerate an extensive for-loop in the C++ MEX function. I initially tried to find an easy way to do this kind of "cross-platform" build strictly inside my 64-bit MATLAB by playing with parameters or command line switches but found it is harder than I thought. The targeted users may use 32 or 64 bit of MATLAB, which means I need to compile the mex files with both architectures. I am recently trying to maintain a few mex files in my Run-on-Stellaris-Launchpad Support Package project.
