Forum Xamarin.iOS

Issues with using OpenTK after update of Xamarin.Mac

AlexanderMaasAlexanderMaas USMember ✭✭

I've been working on a Mac program that uses OpenTK for a while now. I've recently updated to Xamarin.Mac 3.2.0.175. After updating, the following code gives an error:

Error CS0433: The imported type `OpenTK.Matrix4' is defined multiple times (CS0433)

using System;
using OpenTK;
namespace MyMac
{
    public interface IOpenGLObject:IDisposable
    {
        void Init();
        void Render(Matrix4 model_view_projection_matrix);
    }
}

I have included the OpenTK package as I need to have its functionality. However, I noticed that when I use the assembly browser that Xamarin.Mac also contains a definition of OpenTK, which is significantly more reduced than the OpenTK package. Was this already there in previous Xamarin.Mac versions? Is there a work around such that I can still use the full OpenTK library?

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Since the unified transition a while ago we've shipped OpenTK with Xamarin.Mac:

    $ find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/ -name OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/i386/full/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/i386/mobile/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/mono/4.5/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/mono/Xamarin.Mac/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/reference/full/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/reference/mobile/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/reference/net_4_5/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/x86_64/full/OpenTK.dll
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current//lib/x86_64/mobile/OpenTK.dll
    

    However, the behavior of how you reference it should not have changed. Could you post a small example showing this issue or at least the full build log?

  • AlexanderMaasAlexanderMaas USMember ✭✭

    Thanks Chris.

    I've added the OpenTK (2.0.0) package via Nuget, as follows to my references:

    If I don't, code such as shown below fails to build:

    //Generates and set image vertex buffer
                GL.GenBuffers(1, out ImageVertexBuffer);
                GL.BindBuffer(BufferTarget.ArrayBuffer, ImageVertexBuffer);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(ImageVertices.Length * 8 * sizeof(float)), ImageVertices, BufferUsageHint.StaticDraw);
    
                //Get Texture
                Texture = new GLTexture(PixelInternalFormat.Rgba, Width, Height, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
                GL.BindTexture(TextureTarget.Texture2D, Texture.Texture);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.Repeat);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.Repeat);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Nearest);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Nearest);
    

    My full build log is:


  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    So we've been shipping OpenTK.Matrix4 in Xamarin.Mac since at least 2.8, which is multiple years old (before I started here even), so that bit has not changed.

    Maybe something changed with the toolchain?

    Task "Csc" execution -- FAILED
    

    Previous releases we used mcs. Try: xbuild whatever.sln /p:CscToolExe=mcs and see if that behaves differently?

    If so, we can dig into it more.

  • AlexanderMaasAlexanderMaas USMember ✭✭

    Thanks for your quick reply! I've tried the command, but I receive similar output:

    $> xbuild ./VRMouse_Mac.csproj /p:CscToolExe=mcs
    
    XBuild Engine Version 14.0
    Mono, Version 4.8.1.0
    Copyright (C) 2005-2013 Various Mono authors
    
    Build started 4/28/2017 10:11:58 PM.
    __________________________________________________
    Project "/Users/Alexander/Developer/VRMouse/VRMouse_Mac/VRMouse_Mac.csproj" (default target(s)):
        Target _DetectAppManifest:
            FindItemWithLogicalName Task
              Items:
                Info.plist
                Entitlements.plist
                OpenTK.dll.config
                packages.config
              LogicalName: Info.plist
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
        Target _DetectSdkLocations:
            DetectSdkLocations Task
              XamarinSdkRoot: <null>
        Target _CoreCompileImageAssets:
            ACTool Task
              AppManifest: Info.plist
              DeviceModel: <null>
              DeviceOSVersion: <null>
              ImageAssets:
                Resources/Images.xcassets/AppIcons.appiconset/Contents.json
                Resources/Images.xcassets/StatusBarButtonImage.imageset/Contents.json
                Resources/Images.xcassets/StatusBarButtonImage.imageset/[email protected]
                Resources/Images.xcassets/Contents.json
                Resources/Images.xcassets/Mouse-icon.imageset/Contents.json
                Resources/Images.xcassets/Mouse-icon.imageset/Mouse-icon.png
                Resources/Images.xcassets/AppIcons.appiconset/icon_16x16.png
                Resources/Images.xcassets/AppIcons.appiconset/[email protected]
                Resources/Images.xcassets/AppIcons.appiconset/icon_32x32.png
                Resources/Images.xcassets/AppIcons.appiconset/[email protected]
                Resources/Images.xcassets/AppIcons.appiconset/icon_128x128.png
                Resources/Images.xcassets/AppIcons.appiconset/[email protected]
                Resources/Images.xcassets/AppIcons.appiconset/icon_256x256.png
                Resources/Images.xcassets/AppIcons.appiconset/[email protected]
                Resources/Images.xcassets/AppIcons.appiconset/icon_512x512.png
                Resources/Images.xcassets/AppIcons.appiconset/[email protected]
                Resources/Images.xcassets/CropIcon.imageset/Contents.json
                Resources/Images.xcassets/CropIcon.imageset/CropIcon.png
                Resources/Images.xcassets/HelpIcon2x.imageset/Contents.json
                Resources/Images.xcassets/HelpIcon2x.imageset/HelpIcon2x.png
                Resources/Images.xcassets/LogoText.imageset/Contents.json
                Resources/Images.xcassets/LogoText.imageset/LogoText.png
                Resources/Images.xcassets/logo large 2x.imageset/Contents.json
                Resources/Images.xcassets/logo large 2x.imageset/logo large 2x.png
              IntermediateOutputPath: obj/Debug/
              IsWatchApp: False
              OptimizePNGs: False
              OutputPath: bin/Debug/
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
              SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
              SdkPlatform: MacOSX
              SdkVersion: 10.12
            Tool /Applications/Xcode.app/Contents/Developer/usr/bin/actool execution started with arguments: --errors --warnings --notices --output-format xml1 --output-partial-info-plist /Users/Alexander/Developer/VRMouse/VRMouse_Mac/obj/Debug/actool/partial-info.plist --app-icon AppIcons --minimum-deployment-target 10.11 --platform macosx --compile /Users/Alexander/Developer/VRMouse/VRMouse_Mac/obj/Debug/actool/bundle /Users/Alexander/Developer/VRMouse/VRMouse_Mac/obj/Debug/actool/cloned-assets/Resources/Images.xcassets
        Target _CoreCompileInterfaceDefinitions:
            IBTool Task
              AppManifest: Info.plist
              InterfaceDefinitions:
                Main.storyboard
                ViewControllers/ConnectionScreenView.xib
                WindowControllers/CropWindow.xib
                ViewControllers/CropControls.xib
              IntermediateOutputPath: obj/Debug/
              IsWatchApp: False
              IsWatch2App: False
              IsAppExtension: False
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
              SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
              SdkPlatform: MacOSX
              SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
              SdkVersion: 10.12
              BundleResources Output:
                obj/Debug/ibtool/ConnectionScreenView.nib
                obj/Debug/ibtool/CropControls.nib
                obj/Debug/ibtool/CropWindow.nib
                obj/Debug/ibtool/Main.storyboardc/Info.plist
                obj/Debug/ibtool/Main.storyboardc/MainMenu.nib
                obj/Debug/ibtool/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib
                obj/Debug/ibtool/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
              OutputManifests Output:
                obj/Debug/ibtool-manifests/Main.storyboardc
                obj/Debug/ibtool-manifests/ConnectionScreenView.nib
                obj/Debug/ibtool-manifests/CropWindow.nib
                obj/Debug/ibtool-manifests/CropControls.nib
        Target _CoreCompileSceneKitAssets:
            CompileSceneKitAssets Task
              IntermediateOutputPath: obj/Debug/
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
              SceneKitAssets:
              SdkDevPath: /Applications/Xcode.app/Contents/Developer
              SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
              SdkVersion: 10.12
        Target _CollectColladaAssets:
            CollectBundleResources Task
              BundleResources: <null>
              OptimizePropertyLists: False
              OptimizePNGs: False
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
        Target _CoreCompileColladaAssets:
        No input files were specified for target _CoreCompileColladaAssets, skipping.
        Target _CoreCompileTextureAtlases:
            TextureAtlas Task
              AtlasTextures: <null>
              IntermediateOutputPath: obj/Debug/
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
              SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
              SdkDevPath: /Applications/Xcode.app/Contents/Developer
              SdkUsrPath: /Applications/Xcode.app/Contents/Developer/usr
        Target _CollectBundleResources:
            CollectBundleResources Task
              BundleResources:
                Resources/screen.png
                OpenGL/Shaders/reducedTextureShader.fsh
                OpenGL/Shaders/reducedTextureShader.vsh
                OpenGL/Shaders/differenceTextureShader.fsh
                Resources/.DS_Store
                OpenGL/Shaders/clientStatusShader.fsh
                OpenGL/Shaders/unknownDataCounterShader.fsh
                OpenGL/Shaders/blockPuzzleShader.fsh
                OpenGL/Shaders/blockPuzzleShader.vsh
                OpenGL/Shaders/cropShader.fsh
                OpenGL/Shaders/cropShader.vsh
                OpenGL/Shaders/cropRendererShader.fsh
                OpenGL/Shaders/cropRendererShader.vsh
                OpenGL/Shaders/screenCopyRendererShader.fsh
                OpenGL/Shaders/screenCopyRendererShader.vsh
              OptimizePropertyLists: False
              OptimizePNGs: False
              ProjectDir: /Users/Alexander/Developer/VRMouse/VRMouse_Mac
              ResourcePrefix: Resources
        Target ResolveProjectReferences:
            Project "/Users/Alexander/Developer/VRMouse/QRCodeLib/QRCodeLib.csproj" (default target(s)):
                Target PrepareForBuild:
                    Configuration: Debug Platform: AnyCPU
                Target GenerateSatelliteAssemblies:
                No input files were specified for target GenerateSatelliteAssemblies, skipping.
                Target _GenerateTargetFrameworkMonikerAttribute:
                Skipping target "_GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
                Target CoreCompile:
                Skipping target "CoreCompile" because its outputs are up-to-date.
            Done building project "/Users/Alexander/Developer/VRMouse/QRCodeLib/QRCodeLib.csproj".
        Target PrepareForBuild:
            Configuration: Debug Platform: AnyCPU
        Target _UnpackLibraryResources:
            UnpackLibraryResources Task
              Prefix: xammac
              IntermediateOutputPath: obj/Debug/
              NoOverwrite:
                obj/Debug/actool/bundle/AppIcons.icns
                obj/Debug/actool/bundle/Assets.car
                obj/Debug/ibtool/ConnectionScreenView.nib
                obj/Debug/ibtool/CropControls.nib
                obj/Debug/ibtool/CropWindow.nib
                obj/Debug/ibtool/Main.storyboardc/Info.plist
                obj/Debug/ibtool/Main.storyboardc/MainMenu.nib
                obj/Debug/ibtool/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib
                obj/Debug/ibtool/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib
                Resources/screen.png
                OpenGL/Shaders/reducedTextureShader.fsh
                OpenGL/Shaders/reducedTextureShader.vsh
                OpenGL/Shaders/differenceTextureShader.fsh
                Resources/.DS_Store
                OpenGL/Shaders/clientStatusShader.fsh
                OpenGL/Shaders/unknownDataCounterShader.fsh
                OpenGL/Shaders/blockPuzzleShader.fsh
                OpenGL/Shaders/blockPuzzleShader.vsh
                OpenGL/Shaders/cropShader.fsh
                OpenGL/Shaders/cropShader.vsh
                OpenGL/Shaders/cropRendererShader.fsh
                OpenGL/Shaders/cropRendererShader.vsh
                OpenGL/Shaders/screenCopyRendererShader.fsh
                OpenGL/Shaders/screenCopyRendererShader.vsh
              ReferencedLibraries:
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Net.dll
                ../ComputerInterface_Mac/bin/ComputerInterface.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Data.Linq.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Xml.Linq.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Xml.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/mscorlib.dll
                ../packages/OpenTK.2.0.0/lib/net20/OpenTK.dll
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Core.dll
                /Users/Alexander/Developer/VRMouse/QRCodeLib/bin/Debug//MessagingToolkit.QRCode.dll
              TargetFrameworkDirectory:
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/
                /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5//Facades/
        Target GenerateSatelliteAssemblies:
        No input files were specified for target GenerateSatelliteAssemblies, skipping.
        Target _GenerateTargetFrameworkMonikerAttribute:
        Skipping target "_GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
        Target CoreCompile:
            Tool /Library/Frameworks/Mono.framework/Commands/mcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:"obj/Debug/Mirage Server.exe" Main.cs AppDelegate.cs ExternalComputerController.cs OpenGL/OpenGLTextureRenderer.cs OpenGL/IOpenGLObject.cs OpenGL/GLProgram.cs OpenGL/GLTexture.cs OpenGL/ScreenDataRenderer.cs OpenGL/Renderers/ReducedTextureRenderer.cs OpenGL/Renderers/DifferenceTextureRenderer.cs MousePosition.cs QREncoder.cs OpenGL/Renderers/ClientStatusRenderer.cs OpenGL/Renderers/UnknownDataCounterRenderer.cs OpenGL/Renderers/BlockPuzzleRenderer.cs View.cs ViewControllers/ConnectionScreenView.cs ViewControllers/ConnectionScreenView.designer.cs ViewControllers/ConnectionScreenViewController.cs ViewControllers/ConnectionScreenViewController.designer.cs ViewControllers/ViewController.cs ViewControllers/ViewController.designer.cs WindowControllers/CropWindow.cs WindowControllers/CropWindow.designer.cs WindowControllers/CropWindowController.cs WindowControllers/CropWindowController.designer.cs ViewControllers/CropView.cs ViewControllers/CropViewController.cs ViewControllers/CropViewController.designer.cs ViewControllers/CropControls.cs ViewControllers/CropControlsController.cs ViewControllers/CropControls.designer.cs ViewControllers/CropControlsController.designer.cs OpenGL/Renderers/CropRenderer.cs ColorScheme.cs BlueColorScheme.cs ComputerScreenshotCapturer.cs ClientDataAgent.cs DataAgent.cs ProgramVersion.cs ServerDataAgent.cs CG.cs ExternalComputerInput/IByteStreamable.cs ExternalComputerInput/ByteConverterStructs.cs ExternalComputerInput/ScreenRectangle.cs ExternalComputerInput/ByteStreamableList.cs ExternalComputerInput/ByteStreamableRectangle.cs ExternalComputerInput/MovableScreenRectangle.cs ExternalComputerInput/ByteStreamableData.cs ExternalComputerInput/ByteStreamableExternalScreenData.cs ExternalComputerInput/NonOverlapRectangleList.cs ExternalComputerInput/ScreenPoint.cs ExternalComputerInput/ScreenServerDataAgent.cs OpenGL/Renderers/ScreenCopyRenderer.cs /Users/Alexander/Developer/VRMouse/NetworkLibrary/NetworkServer.cs /Users/Alexander/Developer/VRMouse/NetworkLibrary/NetworkClient.cs /Users/Alexander/Developer/VRMouse/NetworkLibrary/NetworkConnectionTCP.cs obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /target:exe /define:"__UNIFIED__;__MAC__;__UNIFIED__;DEBUG" /nostdlib /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Net.dll /reference:../ComputerInterface_Mac/bin/ComputerInterface.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Data.Linq.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Xml.Linq.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Xml.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/mscorlib.dll /reference:../packages/OpenTK.2.0.0/lib/net20/OpenTK.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.Core.dll /reference:/Users/Alexander/Developer/VRMouse/QRCodeLib/bin/Debug//MessagingToolkit.QRCode.dll /warn:4
    OpenGL/IOpenGLObject.cs(9,15): error CS0433: The imported type `OpenTK.Matrix4' is defined multiple times
            /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll (Location of the symbol related to previous error)
            /Users/Alexander/Developer/VRMouse/VRMouse_Mac/../packages/OpenTK.2.0.0/lib/net20/OpenTK.dll (Location of the symbol related to previous error)
    ViewControllers/CropView.cs(21,10): error CS0246: The type or namespace name `MonoMacGameView' could not be found. Are you missing an assembly reference?
    ViewControllers/CropView.cs(24,10): error CS0433: The imported type `OpenTK.Vector4' is defined multiple times
            /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/Xamarin.Mac.dll (Location of the symbol related to previous error)
            /Users/Alexander/Developer/VRMouse/VRMouse_Mac/../packages/OpenTK.2.0.0/lib/net20/OpenTK.dll (Location of the symbol related to previous error)
        Task "Csc" execution -- FAILED
        Done building target "CoreCompile" in project "/Users/Alexander/Developer/VRMouse/VRMouse_Mac/VRMouse_Mac.csproj".-- FAILED
    Done building project "/Users/Alexander/Developer/VRMouse/VRMouse_Mac/VRMouse_Mac.csproj".-- FAILED
    
    Build FAILED.
    Errors:
    
    /Users/Alexander/Developer/VRMouse/VRMouse_Mac/VRMouse_Mac.csproj (default targets) ->
    /Library/Frameworks/Mono.framework/Versions/4.8.1/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->
    
        OpenGL/IOpenGLObject.cs(9,15): error CS0433: The imported type `OpenTK.Matrix4' is defined multiple times
        ViewControllers/CropView.cs(21,10): error CS0246: The type or namespace name `MonoMacGameView' could not be found. Are you missing an assembly reference?
        ViewControllers/CropView.cs(24,10): error CS0433: The imported type `OpenTK.Vector4' is defined multiple times
    
         0 Warning(s)
         3 Error(s)
    
    Time Elapsed 00:00:05.9429870
    
  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    This worked with a previous Xamarin.Mac? Could you possibly file a bug and attach a sample showing the issue?

Sign In or Register to comment.