Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by unity_OEAzALRYPNThtQ · Jan 22, 2018 at 02:14 PM · plugindll

How to use Google Optimization Tools DLLs ?

Hi !

I need to use one algorithm from the Google Optimizations Tools (https://developers.google.com/optimization/). I saw they are distributed as DLLs for C#, so I guess there must be some way to use them in Unity. But I couldn't make it work.

I downloaded the binaries, and dropped Google.OrTools.dll and Google.Protobuf.dll to my Assets. In Visual Studio, when I add the DLLs using "Add reference", they seem to load correctly (I have auto completion). So I wrote some code. But back in Unity, I get compile errors :

 Assets/GameManagement/GameManager.cs(7,7): error CS0246: The type or namespace name `Google' could not be found. Are you missing an assembly reference?

I tried activating the experimental 4.6 .NET framework in the Player menu. It makes a small difference, as it seems this time Google.Protobuf.dll is recognized, as now I get this error :

 Assets/GameManagement/GameManager.cs(7,14): error CS0234: The type or namespace name `OrTools' does not exist in the namespace `Google'. Are you missing an assembly reference?

I noticed a strange thing : Google.Protobuf.dll loads as a "managed" plugin, while Google.OrTools.dll loads as a "native" plugin. But both are supposed to be C# (as far as I understood).

Any idea about how I can make this work ?

Thank you very much !!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by crsn · Jul 13, 2018 at 10:02 PM

I was thinking about using ortools in Unity3D, and I found your question @unity_OEAzALRYPNThtQ


AFAIK C# version of ortools is just a wrapper. That means that there is C# code that calls a C++ dll compiled for x86/x64 architecture under Windows, Linux and OSX distributions.

So, there are some problems.


If you want just to use ortools with supported architectures (windows, linux and osx - x86 and x64), you need a Unity 3D commercial license, because the actual ortools code that will be called is still written as a C++ unmanaged library, and probably that's the missing assembly reference you have in Unity3D.


Keep in mind that a "managed" dll is a dll written in C# (and only in C#), while an "unmanaged" library is a library written in C++. The name difference is that in managed you use a managed memory allocation, provided by .net framework (garbage collection) while in unmanaged you need to take care of memory allocation details (new/delete mechanism in C++).


If you want to use ortools with other targets (arm for example) I guess you'd need to build (crosscompile) ortools for arm, because current distribution of ortools targets x86/x64 version. That is doable, and I would be thrilled to try to do it.

For reference: I did crosscompile external libs written in C using android (x86/x64/arm/can't remember :D), but it required me to use Crystax NDK, because default NDK didn't support (yet) some standard C math function. I don't know if this is the case, but it could save some time :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

125 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Classes that inherit UIBehaviour in a DLL no longer visible in Unity editor. 2 Answers

Marshal C# Method with C++ 0 Answers

Using #if UNITY_DEBUG in DLLs 0 Answers

Placeholder dll with different dependency results in build-error on target platform (WSA) 0 Answers

UnityEngine.UI.dll namespace doesn't exist for 2018.3.0b11 managed plugin 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges