MonoIntegrationGuide.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. Download mono 3.2.3 source from http://download.mono-project.com/sources/.
  2. Mono can be a bit problematic to compile on Windows as MSVC solution is not maintained very often.
  3. Cygwin option that is provided doesn't come with a 64bit configuration, plus it also has errors.
  4. --------------------------------------Compiling with Visual Studio 2012 on Windows 7 x64--------------------------------------------------
  5. - 3.2.3 version is missing "mono.props" file and without it Visual Studio will fail to open some project files. To fix download the .props file
  6. from https://raw.github.com/mono/mono/master/msvc/mono.props and put it in mono-3.2.3\msvc folder before opening any projects or solution
  7. - Even though solution is VS2010, it will only compile with VS2012 unless you change platform toolkit to
  8. v10 for all projects. (Haven't actually tested with VS2010)
  9. - If compiler complains it cannot find pthreads.h make sure to define "HAS_64BITS_ATOMIC" in libmonoutils project (for all configurations)
  10. - In dlmalloc.c change #include <dlmalloc.h> to #include "dlmalloc.h" if compiler complains it cannot find that file
  11. - In "mono-proclib.c" add this bit of code somewhere near the start of the file:
  12. #ifdef HOST_WIN32
  13. #define strtoll _strtoi64
  14. #define strtoull _strtoui64
  15. #endif
  16. - In "threads.c" replace a line in ves_icall_System_Threading_Interlocked_CompareExchange_Long method, from:
  17. return InterlockedCompareExchange64 (location, value, comparand);
  18. to
  19. #ifdef HOST_WIN32
  20. return _InterlockedCompareExchange64 (location, value, comparand);
  21. #else
  22. return InterlockedCompareExchange64 (location, value, comparand);
  23. #endif
  24. InterlockedCompareExchange64 is just a typedef for _InterlockedCompareExchange64 on Windows and for some
  25. reason compiler doesn't realize it (typedefs to intrinstics don't work?). Anyway, so we just reference the intrinsic
  26. directly.
  27. - In "threads.c" replace a line in ves_icall_System_Threading_Thread_VolatileRead8 method, from:
  28. return InterlockedCompareExchange64 (ptr, 0, 0);
  29. to
  30. #ifdef HOST_WIN32
  31. return _InterlockedCompareExchange64 (ptr, 0, 0);
  32. #else
  33. return InterlockedCompareExchange64 (ptr, 0, 0);
  34. #endif
  35. Same problem as previous.
  36. - For all projects and configurations update their property pages under "C/C++->Optimization" and set "Enable Intrinsic Functions" to "Yes"
  37. - You might be able to skip this step.
  38. - In "exceptions-amd64.c" replace line 121:
  39. if (win32_chained_exception_needs_run) {
  40. with
  41. if (mono_win_chained_exception_needs_run) {
  42. - In "exceptions-amd64.c" delete lines 167 and 168:
  43. if (old_win32_toplevel_exception_filter)
  44. SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
  45. - In "exceptions-amd64.c" move line 166 (line # after previous changes) to start of the function:
  46. guint32 ret = 0;
  47. - in threads.c in mono_thread_get_stack_bounds method replace the bit of code under "#if defined(HOST_WIN32)" from:
  48. void* tib = (void*)__readfsdword(0x18);
  49. guint8 *stackTop = (guint8*)*(int*)((char*)tib + 4);
  50. guint8 *stackBottom = (guint8*)*(int*)((char*)tib + 8);
  51. to:
  52. NT_TIB* tib = (NT_TIB*)NtCurrentTeb();
  53. guint8 *stackTop = (guint8*)tib->StackBase;
  54. guint8 *stackBottom = (guint8*)tib->StackLimit;
  55. __readfsdword doesn't exist when building 64bit. Use may use __readgsqword instead but then you need
  56. to double all your offsets. NtCurrentTeb works equally for both 32 and 64 bit builds.
  57. - Build "mono" project.
  58. - You should end up with mono-2.0.dll, mono-2.0.lib, MonoPosixHelper.dll and mono.exe and we are done compiling
  59. -------------------------------Special Banshee-specific changes--------------------------------------------
  60. Move & modify:
  61. MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic) MONO_INTERNAL;
  62. from object-internals.h
  63. to:
  64. MONO_API MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic);
  65. in object.h
  66. In reflection.c change:
  67. MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, gboolean is_dynamic)
  68. to:
  69. MonoClass* mono_class_bind_generic_parameters (MonoClass *klass, int type_argc, MonoType **types, mono_bool is_dynamic)
  70. --------------------------------Integrating Mono into Banshee----------------------------------------------
  71. - Add mono-2.0.dll to (BansheeRootDir)/bin/(Platform)/(Configuration)
  72. - Add mono-2.0.lib to (BansheeRootDir)/Dependencies/lib/(Platform)/(Configuration)
  73. - Install mono 3.2.3 prebuilt binaries
  74. - Copy contents of (PrebuiltMonoFolder)/include/mono/mono-2.0/mono to (BansheeRootDir)/Dependencies/Include/Mono
  75. - Copy folders (PrebuiltMonoFolder)/etc and (PrebuiltMonoFolder)/lib folders into (BansheeRootDir)/bin/Mono
  76. - TODO - Not all files from /lib are needed, but I haven't yet determined which are
  77. - TODO - mono.exe and mono compiler are not used at the moment. Update docs once they are.