Search code examples
monocygwinmingw

Error when compiling mono on windows: i686-pc-mingw32/bin/ld: cannot find -ldl


I am trying to compile mono on windows using cygwin, however when I run make it eventually stops with the following error

make[3]: Entering directory '/cygdrive/c/Projects/mono/mono/metadata'
  CCLD     pedump.exe
/usr/lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
Makefile:1303: recipe for target 'pedump.exe' failed
make[3]: *** [pedump.exe] Error 1
make[3]: Leaving directory '/cygdrive/c/Projects/mono/mono/metadata'
Makefile:434: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/cygdrive/c/Projects/mono/mono'
Makefile:518: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/cygdrive/c/Projects/mono'
Makefile:445: recipe for target 'all' failed
make: *** [all] Error 2

I can only assume I am missing something from my cygwin install but I can't determine what that could be other than it is probably a library called libdl.

I have been following this guide on codeproject and also using this yaml file as reference.


Solution

  • The code project article may not be complete, in the end I got the following to work

    First I used (interpreted from mono/Appveyor.yml)

    setup-x86.exe -qnNdO -R "C:\cygwin" -s "http://cygwin.mirror.constant.com" 
      -l "C:\cygwin\var\cache\setup" -P autoconf -P automake -P bison -P gcc-core 
      -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ 
      -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel 
      -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl
    

    Then from a cygwin prompt (combination of above and code project article "How-to-build-Mono-on-Windows")

    NOCONFIGURE=1 ./autogen.sh --prefix="C:\monoinstall" --with-preview=yes
    ./configure --host=i686-pc-mingw32
    make get-monolite-latest
    make
    mount "C:\monoinstall" /usr/local 
    make install
    
    cd /cygdrive/c/monoinstall/bin
    rm mono
    cp /cygdrive/c/Program Files (x86)/Mono-3.2.3/bin/mono.exe /cygdrive/c/monoinstall/bin
    rm mcs
    cp /cygdrive/c/Program Files (x86)/Mono-3.2.3/bin/mcs.bat /cygdrive/c/monoinstall/bin