Subject: Re: detect linkage against openssl or gcrypt

Re: detect linkage against openssl or gcrypt

From: Peter Stuge <peter_at_stuge.se>
Date: Mon, 29 Jul 2013 14:52:22 +0200

Daniel Stenberg wrote:
> On Sun, 28 Jul 2013, Peter Stuge wrote:
>
>>> libssh2 can be linked against openssl or gcrypt however, so my build
>>> environment needs to know which one in order to trigger the proper
>>> initialisation code and avoid unneeded dependencies.
>>
>> The correct way to do this is through pkg-config. This is precisely the
>> problem that pkg-config solves.
>
> Is it? How would you build your makefile / build scripts with pkg-config
> to figure this out?

Run:

pkg-config --print-requires libssh2
pkg-config --print-requires-private libssh2

If the output is empty then that is a libssh2 bug.

> But I could also imagine a run-time API so that an application can
> figure this out on its own...

It can't be runtime, or applications must depend on every single
crypto lib supported by libssh2, in order to have all symbols
available.

Guenter wrote:
> On 28.07.2013 04:56, Peter Stuge wrote:
>> The correct way to do this is through pkg-config. This is precisely
>> the problem that pkg-config solves.
> on *nix perhaps, but what about other platforms where no pkg-config
> exists - f.e. Windows

There does exist pkg-config for Windows and it should certainly be
used if building with MinGW. If building with MS C then everything
must be hardcoded due to the complete lack of tooling on Windows.

> (or NetWare)?

I guess this is the same as for Windows.

> And what about cross-compiling where I saw too often pkg-config fail?
> Sure, for the later you could argue that either configure or the
> toolchain is somehow broken, but that's reality ...

Most likely neither configure nor toolchain is broken and the problem
is with the user. I encounter very many people who do not know the
difference between PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR, where the
latter is the only thing correct for cross-compilation.

> > But I could also imagine a run-time API so that an application can
> > figure this out on its own...
>
> me too, and while on that we could then also add a flag for zlib ...

See above for why run-time API for determining compile-time decisions
is a really bad idea. Don't do this. The information must be
available at compile-time, and only at compile-time.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-07-29