Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

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

Open
salunkhesagar1386 opened this issue Sep 5, 2019 · 0 comments

Comments

@salunkhesagar1386
Copy link

salunkhesagar1386 commented Sep 5, 2019

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");
    }
}
  1. Build the library. (The .dll file will be created with MonoTestDLL.dll)
  2. 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.

@salunkhesagar1386 salunkhesagar1386 changed the title C++ library generated using Embeddinator is failing to load in windows application in Visual Studio 2017 Embeddinator fails to generate C++ Static Library from .NET library on Windows Sep 5, 2019
@chamons chamons added this to the Future milestone Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants