Menu

Compiling in MacOS

2018-09-25
2018-10-03
  • Nuno Pedrosa

    Nuno Pedrosa - 2018-09-25

    Hi All,

    Has anybody been able to compile DWSIM in a MAC?
    I have installed Visual studio (what used to be monodevelop) and by using the “beta” update channel I can get the version of mono that has the Roslyn compiler for VB.

    So far so good.
    I open the solution in VS and a lot of the projects get compiled, except the DWSIM.sharedclasses.

    For this one the SGEN executable is unable to do what it needs to do, and running the compiling in diagnostics mode this is what happens:
    `
    Task "SGen"
    /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5/sgen.exe /assembly:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.SharedClasses/obj/Debug/DWSIM.SharedClasses.dll /proxytypes /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM/References/CapeOpen.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM/References/Ciloci.Flee.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.GlobalSettings/bin/Debug/DWSIM.GlobalSettings.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.Interfaces/bin/Debug/DWSIM.Interfaces.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.Serializers.XML/bin/Debug/DWSIM.XMLSerializer.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM/References/FileHelpers.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/packages/Newtonsoft.Json.8.0.3/lib/net45/Newtonsoft.Json.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Core.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Data.DataSetExtensions.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Data.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Drawing.Design.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Drawing.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Windows.Forms.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Xml.dll /reference:/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/4.5-api/System.Xml.Linq.dll /reference:/Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.Controls.DockPanel/WinFormsUI/bin/Debug/WeifenLuo.WinFormsUI.Docking.dll
    Mono Xml Serializer Generator Tool
    Mono version 4.0.30319.42000

    There was an error loading one or more of the types from the referenced assembly /Users/npedrosa/devel/DWSIM/dwsim5/DWSIM.SharedClasses/obj/Debug/DWSIM.SharedClasses.dll
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'WeifenLuo.WinFormsUI.Docking, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'WeifenLuo.WinFormsUI.Docking, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'CapeOpen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=90d5303f0e924b64' or one of its dependencies.
    File name: 'CapeOpen, Version=1.0.0.0, Culture=neutral, PublicKeyToken=90d5303f0e924b64'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    System.IO.FileNotFoundException: Could not load file or assembly 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'DWSIM.Interfaces, Version=5.2.6840.26681, Culture=neutral, PublicKeyToken=null'
    /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(3550,5): error MSB6006: "sgen.exe" exited with code 1.
    Done executing task "SGen" -- FAILED.
    `
    I have checked the command line and all the assemblies mentioned in the /reference: command line exist, but for some reason the seen executable is failing to find them for what ever reason.

    If anybody has a solution that would be great.
    I can use VS in a Windows VM, but that is very inconvenient.

    Thanks,

     
  • Daniel Medeiros

    Daniel Medeiros - 2018-09-25

    Hi Nuno,

    There is a special "monodevelop" branch in dwsim5 repo, but it is 165 commits behind the main one. If the issue is with the DWSIM.Interfaces project not being compiled, you can try adding these lines to the vbproj file as I've did:

    https://github.com/DanWBR/dwsim5/commit/f9db421bd6d0bf7aa1db384b69221fba4b857a2e#diff-3adff300f489dd7c5f8155d8fd8fe6ae

    Check my commits in the monodevelop branch to see the changes I had to do in order to get it compiled on macOS, and maybe you can get the master branch compiled in a few minutes.

    Regards
    Daniel

     
  • Nuno Pedrosa

    Nuno Pedrosa - 2018-10-02

    Hi Daniel,

    thanks for the quick reply.
    I am afraid it still does not work...
    at the moment I get this error:
    DWSIM/dwsim5/DWSIM.UI.Desktop.WPF/Styling.cs(35,35): Error CS0117: 'VirtualizingPanel' does not contain a definition for 'SetVirtualizationMode' (CS0117) (DWSIM.UI.Desktop.WPF)
    I wonder if the WPF project should even be compiled in MacOS.

    I have mac visual studio 7.6.8 with mono 5.12.0.309.

    many thanks,

    Nuno

     
    • Daniel Medeiros

      Daniel Medeiros - 2018-10-02

      Yes, it does. It is needed by the DWSIM.UI.Desktop project (Cross-Platform UI). Try commenting out this line before compiling.

       
  • Nuno Pedrosa

    Nuno Pedrosa - 2018-10-02

    thanks!

    if I do that, I get a new error, this time in a resource file.
    DWSIM/dwsim5/DWSIM/Forms/Flowsheet Components/SpreadsheetForm.resx(5,5): Error MSB3103: Invalid Resx file. Requested value 'Del' was not found. Line 2028, position 5. (MSB3103) (DWSIM)

    if I comment that section too in the resx file it does compile., but with lots of warnings.
    after copying all the files as in the instructions and try to run it with

    mono DWSIM.exe
    

    I get a crash:
    WARNING: The Carbon driver has not been ported to 64bits, and very few parts of Windows.Forms will work properly, or at all
    Stacktrace:

    at <unknown> <0xffffffff>
    at (wrapper managed-to-native) System.Windows.Forms.XplatUICarbon.CGDisplayBounds (intptr) [0x00002] in <34333fb7775c426488164ab5296c19c9>:0
    at System.Windows.Forms.XplatUICarbon.get_WorkingArea () [0x00005] in <34333fb7775c426488164ab5296c19c9>:0</unknown>

    if I try to use the other exe

    mono DWSIM.UI.Desktop.exe
    

    all I get is this:
    You are using dlopen without a full path, retrying by prepending /usr/lib.

    This is showing to be quite tricky!

    Many thanks so far.

     
    • Daniel Medeiros

      Daniel Medeiros - 2018-10-02

      I've never tried to debug the Cross-Platform UI on macOS, because it needs to be run from inside an app bundle. I always compile it and copy to a preconfigured app bundle.

      You can try changing the renderer to Gtk2 (edit dwsim_newui.ini on your documents folder) and see if the exe can be initialized without being inside an app bundle.

       
  • Nuno Pedrosa

    Nuno Pedrosa - 2018-10-03

    Daniel,

    Thanks for all your help.
    I managed to get some progress! edting the ini file and setting the Mac rendeder to Gtk did the trick. ( I am using the monodevelop branch though).
    This time I was running the DWSIM.UI.Desktop.
    Both MonoMac and Winforms options crash.
    The MonoMac one crashes with unknown method in
    platform = new Eto.Mac.Platform();
    which is very odd....

    As for winforms, it seems however that Windows.Forms in mac does not yet work in 64bit mode.
    https://www.mono-project.com/docs/about-mono/supported-platforms/macos/
    From searches it seems that is why it is crashing when using DWSIM.exe.

    I am truly curious as to how you are making this to work in 64bit mode, with MonoMac, and how these app bundles are made...

    I appreciate that you may not have the time to explain all this, but if you do that would be great.

    In any case I got somewhere, altough it looks a bit ugly with GTK :-)

    Again, thanks for you help!

     
  • Daniel Medeiros

    Daniel Medeiros - 2018-10-03

    Hi Nuno,

    Here's how I do some kind of debugging on macOS. First thing you have to do is to download the current macOS package and unpack DWSIM.app into your desktop. Then do the following:

    1. Change the renderer back to MonoMac in the ini file.
    2. Build the project in Release/x64 mode.
    3. Order the contents of the DistPackages/macOS folder to show the last modified files on the top.
    4. Copy all files from the top (last modified, should be DWSIM.exe or DWSIM.UI.Desktop.exe) down to "readme.txt".
    5. Right click on the DWSIM.app bundle on your desktop and click on "Show Package Contents".
    6. Paste the files on the Contents/MonoBundle folder, overwriting the existing ones.
    7. Open a terminal session and type
    MONO_LOG_LEVEL="debug" Desktop/DWSIM.app/Contents/MacOS/Launcher.exec
    
    1. If for some reason DWSIM crashes, go to your documents folder, DWSIM Application Data folder and open the lasterror.txt file to view the exception details.

    That's it. The original app bundle was created with VS on Mac by creating and compiling an empty Xamarin.Mac project , then I've got the generated app bundle and modified it to my needs.

    Regards,
    Daniel

     
  • Daniel Medeiros

    Daniel Medeiros - 2018-10-03

    For the sake of curiosity, the first macOS releases were based on MonoMac, but changed later to Xamarin.Mac due to the first being discontinued and also because of the lack of 64-bit support. This is why the renderer is called "MonoMac".

    The entire Cross-Platform UI is based on the amazing Eto package (https://github.com/picoe/Eto), as you may have noticed already.

     
  • Daniel Medeiros

    Daniel Medeiros - 2018-10-03

    Another curiosity: the app bundle contains an entire Mono distribution by itself, which is the one that Xamarin.Mac is based on. It should work even if you don't have Mono installed on your system.

     
MongoDB Logo MongoDB