distribute my own c++ library - c++

I have already create a static and dynamic library for c++ in ubuntu and I wanna know how I'm gonna distribute this library for others, so they can install it and use it with the same plateform (linux).
I have the file (.h) and files (.so and .a) for the librairy.
Please your help

There're so many ways to share your libs.
One could be creating a github project, with CMakeLists (or other buid system), which would be able to build lib on other people platforms.
Don't forget about the license (:

Related

Android NDK cmake and dependent libraries

I'd like to use a library (source codes from GH) in my JNI code. But the library depends on two other libraries (NTL and Boost) that are not available in Android NDK.
Now I am a bit confused and not sure if I understand correctly my following actions.
C++ code for Android is built into shared libraries (.so) for every platform (x86_64, armv7..). Does this mean that NTL, Boost and the lib I want to use must be compiled by me from source codes for these platforms too? If yes, how to do it correctly with cmake?
If I should build all the libs for specific platforms, how it is better to do, either as static libs (.a + headers) or as shared libs?
Do I really need to build NTL and Boost for all the platforms or I should do it just for the needed library?
Is Android.mk file required or can help with cmake? As I understand, it is used with "ndk-build" only.
Generally, if this sequence of actions is correct?
Build NTL for all platforms (.a + headers)
Build Boost for all platforms (.a + headers)
Build Library for all platforms (.so)
Add Library's .so-file as a dependency in CMakeLists for JNI project. (Do I still need dependent libs and headers or that dependencies will be incapsulated into lib?)
C++ code for Android is built into shared libraries (.so) for every platform (x86_64, armv7..). Does this mean that NTL, Boost and the lib I want to use must be compiled by me from source codes for these platforms too? If yes, how to do it correctly with cmake?
Yes, you'll need to build those libraries from source (or find a binary distribution for Android) if you want to use those libraries in your application. As for how to do that, you'll have to wait for someone else to answer or try Googling it. There are a handful of "how to build X for Android" tutorials out there, but I don't know if you'll find many for CMake since CMake is pretty new for Android.
If I should build all the libs for specific platforms, how it is better to do, either as static libs (.a + headers) or as shared libs?
That mostly depends on how many shared libraries you're building for your app. The ideal model for an app is to use a single shared library in your app and statically link in all of your dependencies (going to avoid linker bugs on old versions of Android, and will make your app as small as possible). If you have multiple shared libraries for your code, you'll need to use shared libraries for your dependencies to avoid ODR issues.
Do I really need to build NTL and Boost for all the platforms or I should do it just for the needed library?
You'll need to do it for any platform you need to use those libraries on.
Is Android.mk file required or can help with cmake? As I understand, it is used with "ndk-build" only.
CMake and ndk-build should both work, but you might have an easier time finding porting instructions for ndk-build due to CMake's relative youth in Android.

C++ Packaging: Finding shared library dependencies

I have build an application in C++ which is linked with 3rd party shared libraries such as opencv. Now I would require to package this application and redistribute as tar files to users, with out having them to install and compile the 3rd party dependencies. Compiling libraries such as opencv in linux/Ubuntu is such a painful process.
Now I will want to find exactly what all specific modules of a library is linked to executable and include them in the distribution tar. I dont want to include the whole library as the size will of the tar will blow up.
Will it be sufficient enough just to include libraries detected by the ldd command? Any guidance or tip-off/starting point would be helpful
By its definition "ldd - print shared object dependencies". Besides, I personally confirm that it works as I always use it in professional projects.
Also you can check the same question and answers here.
https://unix.stackexchange.com/questions/120015/how-to-find-out-the-dynamic-libraries-executables-loads-when-run
The ldd command can be used to show what libraries an executable (or library) is linked to.
I tip that it works for me (after adding all dependencies with ldd) is to install a fresh linux in virtualBox and try the distribution tar as I'd be the final user. That way you can check that everything is ok.

Build C++ library on OS X/Mac using Qt

I have created a C++ library on Windows using Qt and it works well. Now I want to build the same C++ library on OS X/Mac using Qt, and after running the same steps as how I made this C++ library on Windows, I’m not sure which generated files is the library I need on OS X.
On Windows, I can use the library in other C++ project through the following files: .dll, object file library and the header file. I can find the first two files generated in the target folder:
But on Mac, after checking the same folder I found the generated files as below:
Which files are the library that I made? And how to use the generated library in other C++ project on OS X?
I try to find some step-by-step guide but with no luck so far, so if there’s any useful link that will be of help.
Thank you in advance!
The library is
libsdk.1.0.0.dylib
all other libsdk*.dylib are links to the library (compatibility reasons, some applications look for libsdk.dylib). You use these library as you would use any other dynamic library. Supply the library and the header files to the local path or install them system wide (DYLD_LIBRARY_PATH).
See How to use dylib in Mac OS X (C++) for more information.

Using libcurl without installing it

How can I use libcurl with my project without actually installing it or curl on the system?
I want to make my source-code portable, so that any developer can copy the folder with all sources and other files, run make and compile the program without the need for system level installations.
I am looking for (probably separate) solutions for Linux and for Windows (dll?). If it is possible, provide some standard/official solution and not hack (I'd like to be educated about linking third party libraries)
I've used it on Windows using Visual Studio, all you need to do under Windows:
Download the source
Using CMake generate the project files (when using Visual Studio).
Build the libraries, 3 files will be built: libcurl.lib, libcurl_imp.lib and libcurl.dll
Include curl.h in your project and add the paths to your .lib files
Build your program, put libcurl.dll in the executable folder and it will work.
On Linux it should be a similar process, build the libraries and include them with your source.
You probably want to build a static library out of libcurl and link agains it. Should be pretty straightforward and the process is almost identical on every OS.

including boost source files in project using eclipse

I am using boost libraries in an application which is targeted for multiple platforms including android.
unfortunately boost libraries are not included in android so i am trying to include the boost source files in project and compile them but i am getting many errors when i am trying to do that mostly unresolved symbols in many files
i have created the project as a shared library using eclipse ide and os is ubuntu 11.10
please help and i am not really a nerd so easy to understand solution would be really helpful.
Thanks in advance
make a folder called local/include/ in your home folder. Then create a symbolic link from /usr/include/boost to there. Include ~/local/include in the LOCAL_C_INCLUDES variable in your Android.mk. This will work for the header-only libraries in boost.