ViRGIS-Team / gdal-upm

Unity Package for GDAL
MIT License
13 stars 6 forks source link

Add a reference to assembly netstandard 2.0 #8

Closed slanoe closed 2 years ago

slanoe commented 2 years ago

Hello, I have 24 errors like this when I want to build:

Library\PackageCache\com.virgis.gdal@3.4.100\Runtime\Scripts\GdalConfiguration.cs(57,22): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

I use Unity 2018.4.17f1. I want to build a Universal Windows Platform. I select Scripting Runtime Version .NET 4.x Equivalent / Scripting Backend .NET / Api Compatibility Level .NET Standadard 2.0

runette commented 2 years ago

Hmmm

It has not been tested on UWP - only building as Windows, macOS and Linux standalone Players. I probably should be more exact about support.

The GDAL c# binding build process builds the bindings using .NET Standard 2.0. This works well with the Mono Scripting backend in the Windows, macOS and Linux standalone clients.

I think you have experienced this problem :

https://forum.unity.com/threads/2018-2-16f1-uwp-net-scripting-backend-net-standard-2-0-build-errors.588733/

It looks like the solution is to use the IL2CPP scripting backend. Unfortunately, the GDAL c# bindings are built using SWIG and there are several well-documented incompatibilities between SWIG and IL2CPP and GDAL seems to fall down at least one.

I keep meaning to go back and see if there is a fix to make the GDAL DLLs work with IL2CPP - but don't hold your breath.

runette commented 2 years ago

@slanoe I have created a HIGHLY EXPERIMENTAL version using a new approach that MAY :

To use this EXPERIMENTAL version - go to Package Manager and Install from Git Url and use the following Url

https://github.com/ViRGIS-Team/gdal-upm.git#change-to-swig-scripts

This is a change in the UPM package / C# and does not involve any change to the Conda / CPP package - so that should not need to be touched (i.e. the update should not take long - although there will be a fair amount of 'Compiling C# scripts" ... :)

slanoe commented 2 years ago

Hello, Thank you for your quick response. I can't select a git url in Unity version 2018.4.17f1. I have modified directly in the manifest.json:

    "com.virgis.gdal": "https://github.com/ViRGIS-Team/gdal-upm.git#change-to-swig-scripts",

I created a new project with only an empty 3D scene and gdal-upm.

I have many errors like this with same configuration Scripting Runtime Version .NET 4.x Equivalent / Scripting Backend .NET / Api Compatibility Level .NET Standadard 2.0:

Library\PackageCache\com.virgis.gdal@01fa2c141dd73601593922f0887c2ffa1678341e\Runtime\Scripts\osr\CoordinateTransformation.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.virgis.gdal@01fa2c141dd73601593922f0887c2ffa1678341e\Runtime\Scripts\osr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.virgis.gdal@01fa2c141dd73601593922f0887c2ffa1678341e\Runtime\Scripts\ogr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?)
...
runette commented 2 years ago

On Sat, 12 Feb 2022, 06:23 slanoe, @.***> wrote:

Hello, Thank you for your quick response. I can't select a git url in Unity version 2018.4.17f1.

Just a question - is there any reason you area using such an old version?

I can check on Monday - but an update to 2020 or 2021 might help - just by increasing the API support levels. They are also just generally much better product and much more reliable.

I have modified directly in the manifest.json:

"com.virgis.gdal": "https://github.com/ViRGIS-Team/gdal-upm.git#change-to-swig-scripts",

I created a new project with only an empty 3D scene and gdal-upm.

I have many errors like this with same configuration Scripting Runtime Version .NET 4.x Equivalent / Scripting Backend .NET / Api Compatibility Level .NET Standadard 2.0:

@.\Runtime\Scripts\osr\CoordinateTransformation.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) @.\Runtime\Scripts\osr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) @.***\Runtime\Scripts\ogr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) ...

Ok. This means that this configuration does not support System.Runtime.InteropServices. If that is true, then GDAL is never going to work with this config.

Can you try using the IL2CPP accepting backend as suggested by the Unity support ticket I copied in the previous comment. It is probably the best long term solution.

If you are doing that - it would be good to move to 2020.3 or 2021.x - Unity have made a lot of improvements to the AOT in the latter versions.

Reply to this email directly, view it on GitHub https://github.com/ViRGIS-Team/gdal-upm/issues/8#issuecomment-1037015183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARC2MZCOLLOGYW6EGR7BRTU2X4F7ANCNFSM5OBJ43RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

runette commented 2 years ago

This seems to explain the problem ...

https://github.com/swig/swig/issues/455

It looks like GDAL would have to change the entire basis of their SWIG scripts to make this work - many thousands of lines of code and also used for the Python and Java bindings!

Looks like IL2CPP is the only way to go for UWP!

On Sat, 12 Feb 2022, 09:06 Paul Harwood, @.***> wrote:

On Sat, 12 Feb 2022, 06:23 slanoe, @.***> wrote:

Hello, Thank you for your quick response. I can't select a git url in Unity version 2018.4.17f1.

Just a question - is there any reason you area using such an old version?

I can check on Monday - but an update to 2020 or 2021 might help - just by increasing the API support levels. They are also just generally much better product and much more reliable.

I have modified directly in the manifest.json:

"com.virgis.gdal": "https://github.com/ViRGIS-Team/gdal-upm.git#change-to-swig-scripts",

I created a new project with only an empty 3D scene and gdal-upm.

I have many errors like this with same configuration Scripting Runtime Version .NET 4.x Equivalent / Scripting Backend .NET / Api Compatibility Level .NET Standadard 2.0:

@.\Runtime\Scripts\osr\CoordinateTransformation.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) @.\Runtime\Scripts\osr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) @.***\Runtime\Scripts\ogr\AreaOfUse.cs(30,17): error CS0246: The type or namespace name 'HandleRef' could not be found (are you missing a using directive or an assembly reference?) ...

Ok. This means that this configuration does not support System.Runtime.InteropServices. If that is true, then GDAL is never going to work with this config.

Can you try using the IL2CPP accepting backend as suggested by the Unity support ticket I copied in the previous comment. It is probably the best long term solution.

If you are doing that - it would be good to move to 2020.3 or 2021.x - Unity have made a lot of improvements to the AOT in the latter versions.

Reply to this email directly, view it on GitHub https://github.com/ViRGIS-Team/gdal-upm/issues/8#issuecomment-1037015183, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARC2MZCOLLOGYW6EGR7BRTU2X4F7ANCNFSM5OBJ43RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were assigned.Message ID: @.***>

runette commented 2 years ago

@slanoe I created a test project - in 2021.2.7f1. I looks like the .NET script backend is not offered as an option any more - just IL2CPP. I built a small project including GDAL successfully in the UWP player using IL2CPP using the new version.

So I have released the experimental version as version 3.4.102 and I am closing this issue.