Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by Mogrinnar · Mar 01, 2014 at 08:43 PM · pluginstaticdynamiclinking

[SOLVED]Need help using a C++ bundle plugin in Unity3D using Xcode

I am currently trying to use OpenEXR in a Unity3D project.

I compiled all I needed to get the Xcode Project running, which builds great. Using this Unity Documentation I figured out I had to make a bundle. All the kind of builds you can make in Xcode are explained here.

I made a .cpp interface that included the compiled OpenExr libs and builded it as a bundle. Using the documentation I was able to get my unity project to use my bundle and run perfectly!

Now here is my problem : I submitted all of this (including the .bundle file) on my git and when I pulled on another machine, I got a Dll not found exception when I ran the unity project. As you can read here, bundles are described as : " executable files that your program can load at runtime using dynamic linking functions". Now my understanding of static vs linked libraries might be a bit lagging behind but is it possible that the problem simply comes from the fact that I built my bundle dynamically and that my new machine does not have the compiled binaries (in it's usr/local folders) ? I tried to change my Mach-O type from bundle to a static archive library in Xcode (another Mach-O type). Xcode managed to compile and build successfully, but the new "static archive library bundle" did not work in Unity, at least not with my current .cpp interface and .cs Unity interface.

  • Are there other things I would need to set in Xcode for it to work or do static archive library bundles simply not work in unity ?

  • Is there another way to compile everything I need statically ? Having a big bundle file (~below 50MBs) is not a problem for me.

  • If I must work with dynamic bundles, is there a way to package all the necessary compiled files (.a files in my case) inside my project no future teammates can easily checkout/pull the project without having to compile OpenEXR on their own ?

Thank you very much for your help !

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Mogrinnar · Mar 05, 2014 at 03:59 PM

Thanks to Dmitry Pyalov I was able to better understand my problem and narrow my research, which led me to this blog post that solved my problem.

http://www.tedlindstrom.se/how-to-link-dylibs-into-unity3d/

Comment
Add comment · Show 2 · 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
avatar image Orion_78 · Mar 20, 2017 at 02:01 PM 0
Share

This link was very helpful, but is now offline... have to use a web Archive to find it back when needed.

avatar image StanleyGoldman · Apr 21, 2017 at 09:15 PM 0
Share

In efforts to save time for anyone after me...

https://web.archive.org/web/20160831213805/http://www.tedlindstrom.se:80/how-to-link-dylibs-into-unity3d/

avatar image
2

Answer by Dmitry Pyalov · Mar 02, 2014 at 12:40 AM

Did you check the dependencies of your bundle with "otool"? Something like:

 otool -L MyBundle.bundle/Contents/MacOS/MyBundle

Which should return something like:

 MyBundle:
     /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55471.0.0)
     @executable_path/../Frameworks/MonoEmbedRuntime/osx/libmono.0.dylib (compatibility version 1.0.0, current version 1.0.0)
     /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
     /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1056.0.0)
     /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
     /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
     /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
     /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1265.0.0)
     /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.11.0)

If there are any of the dylibs which may not be present on the user machine, then you should bundle them with your app. Also, if those names are absolute (not starting with @executable_path), then you should also patch them with "install_name_tool". Try google on it :) Note, that @executable_path refers to your app binary path, not your bundle binary path.

You can automatically bundle the required dylibs with PostProcessPlayer shell script. Check Unity documentation on it.

Comment
Add comment · Show 2 · 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
avatar image Mogrinnar · Mar 03, 2014 at 01:47 AM 0
Share

Thank you very much Dmitry !

So when you say "If there are any of the dylibs which may not be present on the user machine, then you should bundle them with your app", I should bundle them with my app using the PostProcessPlayer shell script you are talking about ?

Thanks again !

avatar image Dmitry Pyalov · Mar 03, 2014 at 02:01 PM 0
Share

The PostProcessPlayer shell script is the most convenient way to do this, as you need to store those dylibs within your app bundle.

I don't know, maybe if you put them in Assets/Plugins folder, Unity may automatically include them.

You could also try to put them in the plugin bundle, but you need to check paths with "otool", they should start with @executable_path or @loader_path to be successfully loaded from within your bundle.

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

23 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

Related Questions

Prevent objects from bouncing / Stopping on physics boundries (2019.1a10) 0 Answers

My non-static models look black in the Precomputed GI environment 1 Answer

Baked light + dynamic light, same mesh? 1 Answer

Lighting doesn't work when game runs. 2 Answers

How do I remove plugin for iOS builds only 1 Answer


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