Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Gui.cs example win-x64 #7307

josephmoresena opened this Issue Apr 15, 2019 · 1 comment


None yet
2 participants
Copy link

josephmoresena commented Apr 15, 2019

I am trying to compile an executable that includes
When I compile in Linux all is sucessfully, but when I try to compile in Windows I get the following error:
Terminal.obj : error LNK2001: unresolved external symbol dlopen [C:\GitHub\gui.cs\Example\Example.csproj] Terminal.obj : error LNK2001: unresolved external symbol dlsym [C:\GitHub\gui.cs\Example\Example.csproj] bin\Debug\netcoreapp2.2\win-x64\native\Terminal.exe : fatal error LNK1120: 2 unresolved externals [C:\GitHub\gui.cs\Example\Example.csproj]
The problem is related to a [DllImport ("__Internal")] for compatibility with Mono.
I'm using IlCompiler version 1.0.0-alpha-27615-01


This comment has been minimized.

Copy link

jkotas commented Apr 16, 2019

This is duplicate of #2454. We need to make the behavior __Internal configurable to make cases like these work.

As a workaround, you can add the following to your main program when compiling for Windows. It will make it link successfully:

namespace System.Runtime.InteropServices
    public sealed class NativeCallableAttribute : Attribute
        public string EntryPoint;
        public CallingConvention CallingConvention;
        public NativeCallableAttribute() { }

    class MonoStubs
        [NativeCallable(EntryPoint = "dlopen")]
        public static IntPtr dlopen(IntPtr filename, int flags)
            return IntPtr.Zero;

        [NativeCallable(EntryPoint = "dlsym")]
        public static IntPtr dlsym(IntPtr handle, IntPtr symbol)
            return IntPtr.Zero;

@jkotas jkotas added the Interop label Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.