C ++ library requires LibCurl - will application users need libcurl?

I am usually a Java developer, but I'm writing a C ++ library right now, they will use LibCurl. And I am very unaware in the C ++ world!

What I'm writing is an infact library for use by other developers (its client code used to access our API).

Will end users have libcurl installed, or can developers somehow incorporate this into an exe or package somehow?

Actually the same thing, I can use QT in the library, will it be necessary for installation? I assume that it works, so that, of course, developers will need it, but as soon as it is not necessary to compile it into a binary file? Unlike java, where you need Jar files ...

Cheers for any help, Alan

+4
source share
3 answers

If you link libcurl statically, then the end user does not require libcurl, since it will be associated with the executable directly at compile time.

If you bind libcurl dynamically, then the end user requires libcurl to be installed on their system and accessible as a shared library of objects.

However, you are in a different place. You are writing a library for use by other developers. So your end user is not really an end user. In such scenarios, it is β€œbetter” to provide dynamic communication with libcurl.

If you linked statically, then your library will encapsulate a copy of the libcurl library in your code. Now imagine that the developer using your library also uses 10 other libraries, all statically linked to libcurl. This developer will mainly include 10 copies of libcurl in his final product. This is not very efficient and, therefore, dynamic dependency binding is preferable when developing a library.

But...

If a developer uses 10 different libraries that require libcurl, but some of these libraries require an older / newer version than others, then static linking will be useful.

Hope this helps ...

+3
source

Many libraries can be used statically or dynamically linked. Curl is one of them (see, for example, this post , and I would say that this is reasonable. QT is quite large, so you should dynamically bind it, if at all possible. However, even this can be statically linked .

A significant difference between static and dynamic linking is that static linking includes a library in the code of the application object, while in case of dynamic linking the application accesses the library on demand from the installed system.

+2
source

I wrote a closed-source C ++ application that is linked to libcurl in its earlier versions.

This turned out to be a mistake because each version of Linux has a different libcurl. This was much less cross-compatible than glibc and libstdc ++. I did not want to send the libcurl library using the application.

I had simple needs. So I rewrote the application to call curl using system (). This worked on every version of Linux.

0
source

All Articles