[Libwebsockets] compile warning - undefined function

Andy Green andy at warmcat.com
Fri Mar 13 17:57:48 CET 2020

On 3/13/20 4:49 PM, Jaco Kroon wrote:
> Hi Andy,
> https://bugs.gentoo.org/709508 relates.
> /var/tmp/portage/net-libs/libwebsockets-3.2.1/work/libwebsockets-3.2.1/lib/tls/openssl/lws-genec.c: In function ‘BN_bn2binpad’:
> /var/tmp/portage/net-libs/libwebsockets-3.2.1/work/libwebsockets-3.2.1/lib/tls/openssl/lws-genec.c:61:5: error: implicit declaration of function ‘bn_check_top’ [-Werror=implicit-function-declaration]
>     61 |     bn_check_top(a);
>        |     ^~~~~~~~~~~~
> cc1: all warnings being treated as errors
> ninja: build stopped: subcommand failed.
> I dug through my system quickly and honestly I'm not sure what the best way forward here is.

This is almost always due to not running, or problems with, the cmake 
part of building lws.  There's definitely no problem building it on 
1.1.1d on any platform.

> Looks like bn_check_top is a #define in older versions of OpenSSL.  I can confirm it was in openssl 1.0.1 but no longer in 1.1.1d.
> Even then it looks like it was a no-op, as in:
> #define b_check_top(a)
> Unless BN_DEBUG is defined before including.
> So may be OK so simply drop that line completely?
> Alternatively, perhaps wrap the line in #ifdef bn_check_top ...

Mmm if you look at the actual code it's like this

#if !defined(LWS_HAVE_BN_bn2binpad)
int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)
     int i;
     BN_ULONG l;


ie, it's already wrapped with LWS_HAVE_BN_bn2binpad... 1.1.1d has its 
own bn2binpad, which cmake looks for


so presumably on your platform that isn't happening correctly... make a 
temporary ./build2 or whatever and do a fresh cmake in there, check if 
it can find OpenSSL's bn2binpad, if not, search 
./build2/CMakeFiles/CMakeError.log and look for what happened when it 
checked if the function existed.


More information about the Libwebsockets mailing list