Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to attach third-part libraries in release version

I have a program on .NET 4 for Windows. I'm trying to port it for Mac computers with mono and Xamarin studio. I have third-part library EmguCV (it's a wrapper for OpenCV library). I'm using official manual to install it. It installs both OpenCV and EmguCV to

Library/Python/2.7/site-packages/emgucv/lib

When I start program in Debug mode from Xamarin - all works fine. It founds all libraries and use it. But when I make program as "pak" and run on computer without installed EmguCV - I got "DLL not found" exception.

I make my program with this command:

macpack -m:1 -o:. -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/ -r:/Library/Python/2.7/site-packages/emgucv/lib -r:/Library/Python/2.7/site-packages/emgucv/bin -r:Assimp32.dll -r:Assimp64.dll -r:cvextern.dll -r:Emgu.CV.dll -r:Emgu.Util.dll -r:libegl.dll -r:libglesv2.dll -r:OpenTK.dll -r:OpenTK.GLControl.dll -r:RH.AssimpNet.dll -r:RH.HeadEditor.dll -r:RH.ImageListView.dll -r:RH.HeadShop.exe -r:blending.fs -r:blending.vs -r:blendingPl.vs -r:idle.fs -r:idle.vs -r:skelet.vs -r:sprite.png -r:./Libraries -r:./Models -r:./Plugin -r:./Resources -r:./Stages -r:./"Haar Cascades" -n:HeadShop -a:RH.HeadShop.exe

My second and third params should attached EmguCV libraries to my pak:

  • -r:/Library/Python/2.7/site-packages/emgucv/lib
  • -r:/Library/Python/2.7/site-packages/emgucv/bin

And when I'm looking inside pak - I find this libraries. However the program still not found it..

I guess trouble in openCV native libraries, but I can't realize what is wrong :(

like image 862
Artem Kulikov Avatar asked Sep 28 '22 00:09

Artem Kulikov


2 Answers

Well, I spent a lot of time on mac forums :)

The point is that OSX dynamic libraries (*.dylib) have an "install name" that tells the OS where the library expects to be found. So, to work with it - I should change "install name". To do it - I used a tool dylibbundler that changed this name with install_name_tool like this:

install_name_tool -id "@loader_path/dylibs/libcvextern.dylib" libcvextern.dylib

where @loader_path is a special Mac variable, which allows to use relative to application path.

like image 167
Artem Kulikov Avatar answered Nov 15 '22 05:11

Artem Kulikov


These are the things I'd check first. 1. Is your pak complete. Sounds like you may have already checked that. 2. Does your test system have the opencv binaries installed and in the path.

like image 45
Darren Avatar answered Nov 15 '22 06:11

Darren