{"record":{"id":"1fe4699f18abb198","repo":"mono/mono","slug":"this-mono-runtime-is-compiled-for-cross-compiling","errorCode":null,"errorMessage":"This mono runtime is compiled for cross-compiling. Only the --aot option is supported.\n","messagePattern":"This mono runtime is compiled for cross-compiling\\. Only the --aot option is supported\\.\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mono/mini/driver.c","lineNumber":2579,"sourceCode":"\t * If we are not embedded, use the mono runtime executable to run managed exe's.\n\t */\n\t{\n\t\tchar *runtime_path;\n\n\t\truntime_path = mono_w32process_get_path (getpid ());\n\t\tif (runtime_path) {\n\t\t\tmono_w32process_set_cli_launcher (runtime_path);\n\t\t\tg_free (runtime_path);\n\t\t}\n\t}\n#endif\n\n\tif (g_hasenv (\"MONO_XDEBUG\"))\n\t\tenable_debugging = TRUE;\n\n#ifdef MONO_CROSS_COMPILE\n       if (!mono_compile_aot) {\n\t\t   fprintf (stderr, \"This mono runtime is compiled for cross-compiling. Only the --aot option is supported.\\n\");\n\t\t   exit (1);\n       }\n#if TARGET_SIZEOF_VOID_P == 4 && (defined(TARGET_ARM64) || defined(TARGET_AMD64)) && !defined(MONO_ARCH_ILP32)\n       fprintf (stderr, \"Can't cross-compile on 32-bit platforms to 64-bit architecture.\\n\");\n       exit (1);\n#endif\n#endif\n\n\tif (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {\n\t\tg_set_prgname (argv[i]);\n\t}\n\n\tmono_counters_init ();\n\n#ifndef HOST_WIN32\n\tmono_w32handle_init ();\n#endif\n","sourceCodeStart":2561,"sourceCodeEnd":2597,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/mini/driver.c#L2561-L2597","documentation":"Fatal error (exit 1) emitted only in MONO_CROSS_COMPILE builds when the user runs the cross-compiling runtime without requesting AOT compilation (mono_compile_aot is NULL/false). A cross-compiler runtime cannot execute assemblies; it can only produce AOT images, so any other action is rejected.","triggerScenarios":"Running a Mono binary built with MONO_CROSS_COMPILE defined, without an --aot request. The `if (!mono_compile_aot)` guard is true and exit(1) fires.","commonSituations":"Accidentally invoking the cross-compiler `mono` as if it were a normal runtime (e.g. to run a test). Confusing the cross-compile toolchain mono with the host runtime mono on the PATH.","solutions":["Use the cross-compiling mono only with `--aot` to generate native images for the target.","Install/select the host (non-cross) mono runtime on PATH if you intend to execute assemblies.","If running a test, run it on the target device or under qemu with a proper runtime, not the cross-compiler."],"exampleFix":"// before\nmono-cross MyApp.exe   # tried to execute\n\n// after\nmono-cross --aot MyApp.exe   # generate AOT image\n# or to execute: use the host mono runtime","handlingStrategy":"validation","validationCode":"// Detect a cross-compile-only runtime and only allow --aot invocations.\nconst { execSync } = require('child_process');\nfunction isCrossRuntime() {\n  try {\n    const out = execSync('mono --version 2>&1', { encoding: 'utf8' });\n    return /cross|CROSS_COMPILE/i.test(out);\n  } catch { return false; }\n}\nif (isCrossRuntime() && !args.includes('--aot')) {\n  throw new Error('This mono is a cross-compiler; only --aot is supported.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the cross-compiler mono and the host runtime mono on distinct, clearly-named binaries.","Document in your build system which mono binary is for AOT generation vs execution."],"tags":["mono","cross-compile","aot","build-config"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}