0

I have a very simple program:

using System;

public class Program
{
    public static void Main()
    {
        Console.WriteLine(IntPtr.Size);
    }
}

Let's build it with mono compiler as a x86 application and run it on x64 mono:

$ uname -srvmpio ; lsb_release -d
Linux 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Description:    Ubuntu 14.04.1 LTS

$ mono --version
Mono JIT compiler version 3.10.0 (tarball Mon Oct 27 14:33:41 IST 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            sgen

$ mcs -platform:x86 Program.cs

$ mono Program.exe
8

Mono has successfully launched the program. But it has launched my program as a x64 application. If I run this binary file on Windows with Microsoft .NET Runtime, I get 4 in console output (it will be run as a x86 application). So, it is possible to force launch mono runtime as a x86?

AndreyAkinshin
  • 18,603
  • 29
  • 96
  • 155

1 Answers1

1

The -platform:x86 flag is for the compiler. It has no bearing on the memory space allocated to your program by the mono runtime. If you want to run programs as 64 bits you use the 64 bits mono runtime. If you want to run programs as 32 bits you use the 32 bits mono runtime.

This question is thus a duplicate of Mono interop: Loading 32bit shared library does not work on my 64bit system

Community
  • 1
  • 1
Mystra007
  • 275
  • 1
  • 9
  • By the way, I wanted to point out that I spent about an hour looking at mono source code to see if something could help you there. So I didn't just blindly paste the answer from the linked question and declare a duplicate. I actually looked ;) – Mystra007 Dec 09 '14 at 22:44