Best way to distribute program using a Shared library

Asked

Viewed 112 times

1

I wrote a program that uses a library called curlpp. The program is very simple and all it does is make an HTTP request that returns a JSON (use the curlpp to perform this request), parse this JSON (use the jsoncons for this) and print on the screen one of its values. The program has only a file of 50 lines. I am developing on Linux Mint and compiling with the following command:

g++ -o wrapper main.cpp -lcurl -lcurlpp -std=c++11

The generated executable works normally on my computer, however when I try to run it on other computers it says that the curlpp shared library was not found. I know how it works and what the differences are between shared libraries and static libraries, but my question is:

Do I have to force my user to install curlpp before running my program? Can I/should I distribute curlpp together with my program? Is there any way to "join" this library to my compile-time program?

1 answer

2


You need to distribute the library along with your application. You don’t necessarily have to install anything, only the library should be bundled with your application, no matter how you do it. Can be a simple copy.

From what I read in her documentation, the license allows you to freely distribute it without restrictions.

Apparently it has dependencies. So libraries also need to be attached to your application. The libcurl also has no restriction to prevent distribution.

It is possible link the library statically, then its binaries will be incorporated into the executable of your application avoiding external dependencies. For this instead of using the shared library, you need to use the pure library.

You need to read the documentation how to do this for this library specifically. And if it is possible, although almost certain it is. The license allows to do so.

Usually just use the directive -static but no guarantee. You will need to have the curlpp.a.

I only care if the author knows what he’s doing. He says

I don’t have any Licence of VC++ and I don’t want to buy one"

You don’t need to buy any license to have a Microsoft compiler. In fact not only is the compiler free almost always, but Visual Studio simplified as well. And it’s been a while since the almost complete VS (former Professional) is also free.

Documentation of libcurl where it explains what to do to compile statically.

  • Thank you! I chose to distribute the library (libcurlpp.so.0) together with the program and explain how to proceed in README

Browser other questions tagged

You are not signed in. Login or sign up in order to post.