1. I have some C programs which were written on 32-bit machines and work very well on those machines. Of late, for some specific applications, I would like to use same programs on MATLAB (as mex files). The problem is in my work environment I can access MATLAB on 64-bit CentOS 5.2 Linux machines only where my programs yield errors in their outputs in MATLAB (though they do compile; I have set MATLAB to use gcc compiler; gcc version on these amchines is 4.1.2).
2. However, if I compile and run same programs on these 64-bit machines using gcc (on command line) with -m32 option (in my Makefile), they all give correct output.
3. Even if I add -m32 option in CFLAGS under glnxa64 section in mexopts.sh, the mex files don't compile and give following error: (when the name of my c mex file is test_mex.c) /usr/bin/ld: warning: i386 architecture of input file `test_mex.o' is incompatible with i386:x86-64 output /usr/bin/ld: warning: i386 architecture of input file `mexversion.o' is incompatible with i386:x86-64 output
Is there a way I can make MATLAB use 32-bit compiler on this 64-bit machine and make my programs work?