mono/Embeddinator-4000

Embeddinator fails to generate C++ Static Library from .NET library on Windows

Open

#740 opened on 2019年9月5日

GitHub で見る
 (0 comments) (0 reactions) (0 assignees)C# (91 forks)github user discovery
bugchelp wanted

Repository metrics

Stars
 (758 stars)
PR merge metrics
 (PR metrics pending)

説明

I wanted to create a C++ library for a .NET library using Embeddinator-4000.exe. However, when I am setting '--gen=c++', I am getting following exception (Tried with both 32 Bit and 64 Bit Mono versions).

Unhandled Exception: System.NotImplementedException: The method or operation is not implemented. at Embeddinator.Driver.CreateGenerator() at Embeddinator.Driver.Process() at Embeddinator.Driver.Run() at Embeddinator.CLI.Main(String[] args)

As I got stuck for C++ so thought of doing the same by setting '--gen=c'. However, I am getting 'LINK : fatal error LNK1561: entry point must be defined' error.

Steps to Reproduce

  1. Create a 'Class Library (.NET Standard)' project in VS2017 with name 'MonoTestDLL'
  2. Add following code to the class which is default created template

.

public class Class1
{

    public Class1()
    {
        System.Console.WriteLine("Class1 .NET Initialzed Successfully");
    }

    public void PrintMessage()
    {
        System.Console.WriteLine("Class1 .NET In PrintMessage");
    }

    public void PrintMessage(string strStringToPrint)
    {
        System.Console.WriteLine(strStringToPrint);
    }

    public int Add(int iNum1, int iNum2)
    {
        return iNum1 + iNum2;
    }

    static void Main(string[] args)
    {
        System.Console.WriteLine("Class1 .NET In main");
    }
}

3. Build the library. (The .dll file will be created with MonoTestDLL.dll) 4. Now, build the C++ libraries for this .NET dll using Embeddinator-4000 using following command,

Embeddinator-4000.exe --gen=c --platform=Windows --compile --target=static --outdir="C:\Temp\MonoLibs" "${SolutionDir}\bin\Debug\netstandard2.0\MonoTestDLL.dll"

Note: You can replace the path of dll per solution location

  1. Observe following error,

LINK : fatal error LNK1561: entry point must be defined Failed to compile generated code.

  1. I tried by manually adding the main function to C# class, but no luck.

Expected Behavior

Command execution shall work fine and I am expecting 'MonoTestDLL.lib' and wrapper files to be generated by the Embeddinator tool which I can further use in my C++ executable or library.

Actual Behavior

Fails with exception

Environment

Windows Installed Mono and Embeddinator using VS2017 NuGet package.

Set paths of Mono and Embeddinator executable folder in environment variables using %PATH% on command prompt to avoid errors.

コントリビューターガイド