How to add libcurl dependency without getting bound to openssl version - c

I compile my Linux app on Debian Wheezy. It runs and works on all Linux distros.
Recently, I added a dependency of libcurl (needed to make some https requests), now my app doesn't work on Linux distros which don't have libssl.so.1.0.0 present like fedora ships OpenSSL version 1.1.
I just needed a libcurl dependency and got caught in this openssl version issue. My app doesn't care which OpenSSL lib is installed, it just needs libcurl to run, so is this possible to add libcurl.so as a dependency only and installed libcurl will automatically use the ssl lib it was compiled for.

Your app does not care about which OpenSSL is installed - but LIBCURL does ;-)
So, in order to use libcurl as you are expecting, I guess you will have to use libcurl as a static library, compiled with SSL using OpenSSL - which should also be a static library. Optionally, you could use libtool to merge them into a single library.
How to build it? => https://curl.haxx.se/docs/install.html

Related

Does curl need openssl at runtime?

Curl lists openSSL as an external dependency on https://curl.se/docs/libs.html.
However, if I do otool -L $(which curl) (macOS 12.5) I get the following output:
/usr/bin/curl:
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.120.1)
No openSSL. Is this because it is only needed to compile/build curl but is not needed as an external library at runtime?
Will curl still work if I delete openSSL?
If your curl knows how to speak HTTPS or any other protocol that needs TLS, then your curl depends on a TLS library.
OpenSSL is one such a library, but curl currently supports 13 different TLS libraries that it can be built to use.
If your curl speaks a TLS protocol, it depends on one of those supported libraries. On macOS, Apple seems to have favored libressl lately but in the past they also made builds using Secure Transport directly.
The curl -V output shows which TLS library it uses in the first line, but it might take a little experience to fully understand it. TLS libraries mentioned within parentheses there are optionally enabled by the application at start.
The libraries showed in the otool output are dynamically linked at run-time. It means they need to be present and loadable when you invoke curl so that the run-time linker can load them and execute curl fine.
If you build curl yourself or download someone else's build, you can also link it statically and then all the libraries can be built into a single huge binary blob, but that is not how curl is usually built and shipped in operating systems like macOS and Linux distributions.

Installing Kaldi on MacOS Catalina -- error with zlib

I am trying to work with the DiscVoice Library which requires the Kaldi Library. In order to install Kaldi, I needed to run extras/check_dependencies.sh to check the dependencies of the program, and I am currently getting:
extras/check_dependencies.sh: zlib is not installed.
extras/check_dependencies.sh: The following prerequisites are missing; install them first:
zlib1g-dev
I have been trying to install the zlib library, and have been unsuccessful. I have tried brew install zlib, which runs successfully but when I run the extras/check_dependencies.sh the output is not changed to reflect that.
I am working on macOS Catalina.
zlib is already there in macOS. You don't need to install it.
You might want to examine extras/check_dependencies.sh to see how it is looking for zlib. macOS does not store its headers files or library files in the usual locations.

Compiling libuv with libwebsockets

I am trying to run the "libwebsockets-test-server" that is installed with the LWS library, but it will not run because "lwsts[31616]: libuv support not compiled in".
I have checked that libuv is installed (1.8.0). I also changed the setting for LIBUV in cmake and recompiled the library.
LWS_USE_LIBUV = 1
How do I get the project compiled with libuv?
I am on Ubuntu 16.04, cross-compiling using arm-linux-gcc. I have successfully compiled programs, loaded them to the embedded board (TS-7800), and run the executable, but not yet with LWS. I am relatively new to Linux and cross-compilers.
Configuring the cmake using 'cmake -DLWS_WITH_PLUGINS=1', changes the configuration to set LWS_USE_LIBUV equal to 1 and compiles libuv with the make.
Since I was planning to use plugins with LWSWS, this was an appropriate fix for the problem.

Macports register existing library built from source

How can I tell MacPorts that I already have a certain library installed?
For example, I built libcurl from scratch to get http2 protocol with nghttp2, openssl and zlib. I installed them to /opt/local -- same location as all MacPort libs on my system. However, Macports doesn't recognize that they are installed already.
How can I tell MacPorts that these are already installed as well as their versions? Why? Because I'm trying to do:
port install py35-pip but it lists that libz and openssl are not installed.
MacPorts does not support this, for multiple reasons:
You should not manually modify files in /opt/local that would usually be managed by MacPorts. MacPorts keeps certain metadata (like the required dependencies) about installed files, which no longer works when you manually install files in /opt/local.
MacPorts does not know which configuration you used to build the binary that you manually installed in /opt/local. It could be a version that no longer works with a certain dependency, it could be built against a different C++ standard library in case of C++ code, or it could be incompatible for a number of other reasons. Because MacPorts wants to reduce the support burden for requests from people that have modified some of their ports like that, it is not a support feature of MacPorts to do that.
However, MacPorts already supports installing curl with nghttp2 support. See the output of port variants curl:
curl has the variants:
ares: Support resolving names asynchronously
darwinssl: Allow secure connections using GNU TLS
* conflicts with gnutls ssl wolfssl
gnutls: Allow secure connections using GNU TLS
* conflicts with darwinssl ssl wolfssl
gss: Support the Generic Security Service API
http2: Support HTTP/2 with nghttp2
idn: Enable support for internationalized domain names (IDN)
metalink: Support Metalink XML download description files
openldap: Support performing Lightweight Directory Access Protocol queries with OpenLDAP
sftp_scp: Support SFTP/SCP connections via libssh2
spnego: Enable SPNEGO authentication support
[+]ssl: Allow secure connections using OpenSSL
* conflicts with darwinssl gnutls wolfssl
universal: Build for multiple architectures
wolfssl: Allow secure connections using wolfSSL, formerly CyaSSL
* conflicts with darwinssl gnutls ssl
So in this case, you can just install curl +http2, either using sudo port install curl +http2 (if you didn't have it installed already) or using sudo port upgrade --enforce-variants curl +http2 (if you had it installed already) to achieve the same thing.
See also https://trac.macports.org/wiki/FAQ#usrlocal for /usr/local and MacPorts in general.

Build Cyrus SASL as static library on Windows

I need the library Cyrus SASL as a static library on Windows (https://cyrusimap.org/mediawiki/index.php/Downloads#SASL_Library)
How to do that ?
As far as I know, you will need a MinGW and MSYS environment and then just build the SASL from sources like it were on Unix-like, i. e.
./configure
make
make install
You will get some *.a files -- those are static libraries, built with MinGW, they should work for Windows.
I'm still checking this topic, so I'll add some more info if I'm done with it.
For more reference about building projects from sources check the INSTALL file in your project's root directory, i. e. cyrus-sasl-<version>/INSTALL
upd: this seems to be not an easy thing to do, check out this article
upd2: if you prefer Visual Studio, you could check this rather outdated howto.
upd3: in general good article from GNU

Resources