Getting/compiling Mono-2.0.dll for embedding

2019-02-25 09:13发布

问题:

I am trying to implement some scripting in a C application using mono (cf this page http://www.mono-project.com/Embedding_Mono). However I need mono-2.0.dll for this to work. First I thought it was included with binary distribution of mono. But i could not find it in mono installation folder.

I also tryied to build mono myself but the build always finishes with an error (unresolved symbols, read write protected files, and many others). I tryed both cygwin and VS builds.

After a quick search I found other people with similar problems. But unfortunatly no solutions that would work for me.

Is there a solution to easily compile mono-2.0.dll or to get binaries?

Thanks

回答1:

EDIT

IMHO the library that you are looking for may be found in the bin directory of the mono installation folder. Actually, after installing mono 3.2.3 there are two libraries in the MONO_INSTALLATION_PATH\bin\ directory: libmonoboehm-2.0.dll and libmonosgen-2.0.dll (you must choose either Boehm or SGen GC implementation)

You could create a symbolic link like this libmono-2.0.dll -> /opt/mymono/bin/libmonoboehm-2.0.dll if for example you want to use the Boehm implementation. And that is all (I think)

But you could work even without creating any symolic link, you could reference the library monoboehm-2.0.dll or monosgen-2.0.dll instead of mono-2.0.dll. The problem was (I think) you were looking for the wrong library's name.

Anyhow, what follows are the steps that must be followed in order to compile mono from cygwin.

END EDIT

I managed to compile Mono from Windows 8 using cygwin (I guess, it also should work with Windows 7)

These are the steps that I had to follow in order to finish having the mono virtual machine and your requested library:

  1. Download and install a fresh cygwin installation for 32-bit (do not use the cygwin's 64-bit version even if you are using Windows 64-bit) In my case the cygwin version is 2.844 (32 bit) and my operative system is Windows 8 64-bit. Even if you already have a cygwin environment it should be better (IMHO) to remove it and install and new fresh cygwin environment.

  2. The cygwin's installation path should be (at least in my case) in: C:\cygwin

  3. Using cygwin you must install some required dependencies running setup-86.exe. Without them, you are not going to be able to compile mono from cygwin:

    autoconf, automake, bison, gcc-core, gcc-g++, mingw-gcc, libtool, make, python, automake, bison, gcc, gdb, gettext, intltool, libiconv, libtool, pkg-config, vim

  4. Open a cygwin console and run these commands:

    Me@mewin8 ~ $ mkdir -p /opt/mono323

    Me@mewin8 ~ $ mkdir -p /opt/mymono

    Me@mewin8 ~ $ cd /opt

    Me@mewin8 /opt $ git clone https://github.com/mono/mono.git

    Me@mewin8 /opt $ cd mono

    Me@mewin8 /opt/mono $ git submodule init

    Me@mewin8 /opt/mono $ git checkout --track origin/mono-3.4.0-branch

  5. Outside cygwin console download mono for Windows (you are going to need it when compiling mono from cygwin): http://download.mono-project.com/archive/3.2.3/windows-installer/mono-3.2.3-gtksharp-2.12.11-win32-0.exe

  6. Install mono for Windows in C:\cygwin\opt\mono323

  7. Go again to the cygwin console and run these commands:

    Me@mewin8 ~ $ cd /opt/mono

    Me@mewin8 /opt/mono $ export PATH=$PATH:/opt/mono323/bin

    Me@mewin8 /opt/mono $ ./autogen.sh --host=i686-pc-mingw32 --prefix=/opt/mymono/

    Me@mewin8 /opt/mono $ make

  8. The compilation ends with error. See this thread: mono from git will not build on cygwin 32 Solution:

    Me@mewin8 /opt/mono $ vim /usr/i686-pc-mingw32/sys-root/mingw/include/ddk/ntapi.h

    Comment out this line typedef PVOID PEXECUTION_STATE; If you have followed the same steps as me, the line to be commented out should be the number 49. You must finish having //typedef PVOID PEXECUTION_STATE;

  9. Restart compilation:

    Me@mewin8 /opt/mono $ make clean

    Me@mewin8 /opt/mono $ make

    Me@mewin8 /opt/mono $ make install

  10. You may find your requested library in this path (actually you finish having two):

    • Implementation using Boehm GC: /opt/mymono/bin/libmonoboehm-2.0.dll

    • Implementation using SGen GC: /opt/mymono/bin/libmonosgen-2.0.dll

    You could create a symbolic link like this: /opt/mymono/lib/libmono-2.0.dll -> /opt/mymono/bin/libmonoboehm-2.0.dll; or like this one: /opt/mymono/lib/mono-2.0.dll -> /opt/mymono/bin/libmonoboehm-2.0.dll (whatever works for you)

    Depending on how you are going to work with the library, the symbolic link could be interesting for you or not.

  11. Besides, if gcc/ld may not find your library while trying to build your own program (I mean the program where you are going to embed mono) and you are trying to compile from a cygwin console you could do this:

    export LD_LIBRARY_PATH=/opt/mymono/lib See: man ld

This is all I know. Hopefully it will help you... At least I tried my best!



标签: dll mono