Deploying and distributing OpenCV applications with Xcode4 on Mac OSX

I am working on an OpenCV application, and my question is how can I deploy and distribute the application on machines without development, on machines where OpenCV is not installed?

I am using Xcode4 on Mac OS X Lion with OpenCV 2.2.

thanks

+7
source share
2 answers

This is only a partial answer, because I have not yet figured out how to do this with OpenCV libraries. ( Found this out. See update below. ). But I did it with other libraries ( SM2DGraphView ).

There are three things that must happen:

  • You need to copy the OpenCV libraries that your program uses in the application suite. To do this (in Xcode 3, anyway) add the build phase of the copy files to your target. Drag library files from the Xcode file list to the build phase. Double-click Copy Files and specify a destination in Structures.

    Note that you need to make sure that the library that you included in the Xcode project is a library file, not a symbolic link to a library file. Otherwise, only the symbolic link will be copied to your application package.

  • The installation path of the OpenCV framework files must be installed in the @executable_path/../Framework . If the structure was built in Xcode, you must do this in the project settings. Since OpenCV is not built in Xcode, you need to do this after the fact using the install_name_tool command-line install_name_tool : install_name_tool -id @executable_path/../Frameworks libopencv_imgproc.2.3.1.dylib . You should be able to set this in the execution phase of the Script for your purpose.

  • The executable should find the library in the Frameworks directory. That's where I'm stuck right now.

Update

I found the correct install_name_tool commands so that the program can see the libraries (and libraries for viewing other libraries). The key was the Qt page for deploying OS X programs .

I ran otool -L in the executable file in the "Contents / MacOS" folder of the program and saw that these [inapplicable lines were deleted]:

 lib/libopencv_core.2.3.dylib (compatibility version 2.3.0, current version 2.3.1) lib/libopencv_imgproc.2.3.dylib (compatibility version 2.3.0, current version 2.3.1) lib/libopencv_highgui.2.3.dylib (compatibility version 2.3.0, current version 2.3.1) 

Therefore, I used these commands (in the Contents / MacOS directory) to make the program look in the right place for the libraries:

 install_name_tool -change lib/libopencv_core.2.3.dylib @executable_path/../Frameworks/libopencv_core.2.3.1.dylib CocoaCVTest install_name_tool -change lib/libopencv_imgproc.2.3.dylib @executable_path/../Frameworks/libopencv_imgproc.2.3.1.dylib CocoaCVTest install_name_tool -change lib/libopencv_highgui.2.3.dylib @executable_path/../Frameworks/libopencv_highgui.2.3.1.dylib CocoaCVTest 

Then I went to the Contents / Frameworks directory and used these commands to tell the libraries where they were installed:

 install_name_tool -id @executable_path/../Frameworks/libopencv_core.2.3.1.dylib libopencv_core.2.3.1.dylib install_name_tool -id @executable_path/../Frameworks/libopencv_imgproc.2.3.1.dylib libopencv_imgproc.2.3.1.dylib install_name_tool -id @executable_path/../Frameworks/libopencv_highgui.2.3.1.dylib libopencv_highgui.2.3.1.dylib 

Now the imgproc library needs to be told where to find the main library, and it is necessary to indicate where to find highgui, where to find the kernel and imgproc:

 install_name_tool -change lib/libopencv_core.2.3.dylib @executable_path/../Frameworks/libopencv_core.2.3.1.dylib libopencv_imgproc.2.3.1.dylib install_name_tool -change lib/libopencv_core.2.3.dylib @executable_path/../Frameworks/libopencv_core.2.3.1.dylib libopencv_highgui.2.3.1.dylib install_name_tool -change lib/libopencv_imgproc.2.3.dylib @executable_path/../Frameworks/libopencv_imgproc.2.3.1.dylib libopencv_highgui.2.3.1.dylib 

I still run into a problem when highgui searches a lot of libraries in / opt / local / bin, but I'm pretty sure that part of the OpenCV problem has been resolved. Now I just need to get all these commands in the build phase in Xcode.

+4
source

I would advise using a cross-platform compiler (e.g. improved autotool). Very common is CMake, which is not so easy to use, but not so complicated, not only ordinary, it is used by OpenCV ...

  • 1) Write your application on your development machine and write Cmake (do not forget to write a part to use OpenCV Cmake)

  • 2) Submit your cmake and opencv files to a non-development library

  • 3) Create an application on the target platform with CMake script, if you have written it correctly, it can create opencv (using its own OpenCV Cmake) and create your application (with the one you wrote)

If you want to go further, you can create an installation wizard or package using CPack to automate everything.

Here is the link where you can download it

Julien

+1
source

All Articles