how to distribute osx program that uses dylibs? - c++

I wrote a small program (osx, c++) for image joining using opencv2 but I ran into a problem trying to send it to my friend who i wrote it for. The problem is that I only found two ways to build opencv2 and I could only build it into .dylib and .a files. I didn't know how to properly compile with the .a files and when i compile with .dylib files I couldn't make the program find them on another computer. How do I distribute a program that uses .dylib files for osx. I found a few answers to similar questions that mentioned changing the Dynamic Library Install Name in xcode and using the install_name_tool, but neither one of those helped or maybe I just used them wrong. I also tried finding a way to build opencv2 into a .framework for osx (not ios), but had no luck in my searches. I don't know where else to turn at this point.

Related

open cv and c++ compile release without need library for run

first i have simple code with c++ and opencv
its no matter what is the code
now in windows i used visual studio and i add the open cv library to visual stuio and compile it and its work but when i send it to another pc its need open cv library its hard to send all library so i find the program need some files like
opencv_highgui2410.dll
..... .dll
opencv_objdetect2410.dll
that's make my program run without the library
now i turned to ubuntu linux after i compile with codeblocks
this photo will show you how i linker the library
and
and i build the program and run it its work now when i sent the program to another pc its give an error some files not found like
error while loading shared libraries: libopencv_core.so.2.4
i copy this file libopencv_core.so.2.4 and add it beside the program still same error seems not like windows
any solution made me compile opencv program and run program without need full library just some of its file
or any idea to add files (libs) that's project needed to run beside program just like windows
I think this should help you.
But from the comments, i fear you have very little linux experience, I hope this will help, anyway:
https://s1meonov.wordpress.com/2010/12/27/opencv-static-linking-gnulinux-gcc/
(first, be sure to understand what shared and static libraries, how they work and how they impact on software licenses, and also be sure to understand how to install programs in linux. For installing have a look at this link: http://www.makeuseof.com/tag/beginners-guide-installing-software-ubuntu-apt/)

How to convert .lib file to .a

I've spent the last 5 hours trying to link a binary file to my program, I am using eclipse + MinGW, and trying to include the FreeImage source (downloaded from internet), the thing is I am unable to include the .lib file since it doesn't work, so I am trying to convert it to .a file.
I used MSYS software in order to do it, but nothing is working, the errors go, but the the program just fails/crashes.
Is there a way to convert .lib files to .a files so I can include them to my program.
Please help me, I really need this, and I've looked so hard to find some solutions, nothing worked, someone please direct me.
Thanks in advance <3
See this answer. It recommends http://code.google.com/p/lib2a/
You must compile opencv with gcc-mingw. gcc-mingw compiles for a different operating system - mingw is a subset of Linux. Libraries compiled for Windows are simply not compatible.
You can easily find instructions for building opencv for mingw using google, or here:
Getting started with OpenCV 2.4 and MinGW on Windows 7
You'll also need to compile FreeImage, the source code for FreeImage is available at http://freeimage.sourceforge.net/download.html

(C++) How to use OpenBlas libraries with C++?

Sorry if this all seems too simple but I'm a beginner and I'm trying to use the OpenBlas libraries in my C++ IDE "CodeBlocks" on Windows. More specifically, I'm want to use the matrix-vector multiplication and solving of a tri-diagonal matrix system libraries. I've downloaded the files at the bottom of the page on the OpenBlas site. I'm not sure how I would even start, as there are little/no resources online for beginners such as myself. What libraries do I need to include in my .cpp file preamble, have I even downloaded the correct set of files, which files do I need to include in my working directory, etc?
Thanks in advance.
EDIT: I've downloaded the pre-built files as recommended and followed every step in the link below.
http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/
I have also included #include "cblas.h" in the preamble of my .cpp file but I am getting a undefined reference to 'cblas_XXXXX' error in my build messages. What is the reason for this?
Download the pre-built winodws library
https://sourceforge.net/projects/openblas/files/v0.2.15/OpenBLAS-v0.2.15-Win64-int32.zip/download

I'm lost in boost libraries (specifically boost_program_options)

Hi all I've been banging my head against the wall all day now.
So I want to move my program onto the university supercomputer, but it doesn't have boost (and I used boost program_options in my code). On my pc, I just have -lboost_program_options and that works fine, but obviously won't work anymore.
So, I need to package the necessary stuff along with my code so that it will compile on the supercomputer (using intel icpc)
My first hurdle was compiling the line in my makefile that had the code that wanted to include the boost header, but I ran the following in my code folder:
bcp --scan --boost=/usr/include/ main.cpp destination_folder/
And put the resulting files in my include directory. which solved that.
Boost program options isn't a header only package unfortunately, so i need something else. I need to get a library or something. Because i get errors when the compiler gets to the last task on my makefile (doing all the object files)
In my travels I found this question:
extractin/building boost program_options
I tried what the answer suggests, but putting "build" in my command doesn't generate any extra files...
Now totally stuck, don't know how to get this library thing. I've read so much stuff on bjam my head is spinning, I just don't have the level of understanding to process it all in my head.
OS: Linux both systems
One option is to build boost on that machine. Install it in your home. Change your CXXFLAGS and LDDFLAGS to point to the proper header and library directories and build your code there.
The other option is to cross compile both on your PC (if you have such a cross toolchain). Link your code statically to boost and take the final binary to the super computer.
Since both systems are linux, you'll just want to use the binaries. If both systems run on the same CPU, just compile your program statically. If not, download the debian package for the architecture your supercomputer runs on and rip headers and binaries from that.
I've build boost from bjam for cross-compiling to windows, and if there ever was a reason to use the autotools in a project, it's the mess of boost and bjam. Avoid it if possible, and try to adapt the debian package source if you can't.
Instead of building Boost.ProgramOptions you could include and compile all its .cpp files within your project.

Trouble with boost and Code::Blocks

I've been trying to get the boost library working with Code::Blocks and am having some trouble.
When I first tried to get boost, all I did was download the latest zip file and extract it into the CodeBlocks folder. Then I set the compiler settings to look in the boost folder. This allowed me to compile, but not to link. I then read the BoostWindowsQuickReference. I removed everything I had related to boost from my machine, and started fresh.
I followed the instructions step by step, and the only thing that didn't go exactly as the instructions said was that the install-proper folder with the include\boost inside of it was in C: and not my CodeBlocks folder. So I simply copied it (just in case for some reason it needed to be there) to the CodeBlocks folder, which I thought odd because I already had a boost_1_40_0 folder there from downloading the .zip.
I then tried to compile a program and it came up with the exact same error. Then I realized that I forgot to put in the link library (Ex: boost_regex-mgw44-mt-1_40.lib). Now I get
error: ld.exe||cannot find -lboost_regex-mgw44-mt-1_40.lib|
I have a few questions:
Obviously, what am I doing wrong?
Will I need to put in a link library every time I want to use a boost facility (everything is separated into different files, there isn't just one big project.)
Was it necessary to build the library with the boost-jam or could I have just extracted it and used it? (Probably a dumb question, but a small seed of doubt was planted when I got the exact same error.)
Should I try nuwen's MinGW Distro? (Would it make things any easier?)
If any clarification is needed I'd be happy to do so. Thanks.
Edit: and now I can't compile regular programs. So I'm just starting fresh again.
1, it should be -lboost_regex-mgw44-mt-1_40
2, Read the document, most boost library doesn't require to link library
3,4, You should compile it yourself, or try nuwen's MinGW ( I'd installed it and it worked fine )
BoostPro has Windows binaries available for the Boost libraries. If you download just the Boost sources, you will have to compile it, if you are using any of the libraries that are not header-only (such as boost regex). The BoostPro binaries will allow you to link to these without having to build anything.
On Windows it doesn't really matter where you "install" Boost to. Just get the .7z, compile using bjam.exe and pass it the options you need. It will create a folder called "bin.v2" and put the resulting libs in there. In Code::Blocks, all you need to do is edit the project options and point the search path to boost_1_40_0\boost and manually input the libraries to link against (those from bin.v2). It should just work then.
Do not use a precompiled Boost library.