On 11/12/2012 07:23, NBM wrote:
> Having written a lot of code on M8, I recently switched to M9 and tried to
> run the code which starts by loading an .mx file written by M8, but M9 wouldn't read it saying that it was written on another machine. This is a major incompatibility issue between M8 and M9. Fortunately I kept my M8 installation, so for now, M9 is useless to me.
> Please a solution.
>
As others have commented, you can't move .MX files:
1) Between versions of Mathematica.
2) Between 32 and 64-bit implementations.
3) (Possibly) between different platforms (Windows, Linux,etc.)
I used to use .mx files to store some really large partly symbolic
expressions, because the saving and the read back were both fast. After
some experimentation, I found that this was a good portable alternative:
str=OpenWrite[file,BinaryFormat->True];
BinaryWrite[str,magic,"TerminatedString"];
BinaryWrite[str,Compress[{expr,version}],"TerminatedString"];
Close[str]
(where expr containd the expression, and magic is some short string that
enables you to do a sanity check when you read the file back in.
This is not quite as fast as using .mx, but it still seems faster than
other alternatives.
Read the stuff back with two calls to BinaryRead[str,"TerminatedString"],
checking the first, and uncompressing the second.
Compress and Uncompress seem extraordinarily efficient applied to large
expressions.
David Bailey
http://www.dbaileyconsultancy.co.uk