5

I'm trying to build curl with boringssl on Ubuntu 16.04.

I have boringssl built OK.

With curl 7.53 I configure using:

./configure --with-ssl=/home/john/dev/boringssl

and the output says " SSL support: enabled (BoringSSL)" OK.

But when I make, I get errors starting with

  CC       vtls/libcurl_la-openssl.lo
In file included from vtls/openssl.c:86:0:
/usr/include/openssl/ui.h:85:1: error: unknown type name ‘UI’
 UI *UI_new(void);
 ^
/usr/include/openssl/ui.h:86:1: error: unknown type name ‘UI’
 UI *UI_new_method(const UI_METHOD *method);
 ^
/usr/include/openssl/ui.h:86:25: error: unknown type name ‘UI_METHOD’
 UI *UI_new_method(const UI_METHOD *method);
                         ^

and ending with

Makefile:2023: recipe for target 'vtls/libcurl_la-openssl.lo' failed
make[2]: *** [vtls/libcurl_la-openssl.lo] Error 1
make[2]: Leaving directory '/home/john/dev/curl-7.53.0/lib'
Makefile:734: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/john/dev/curl-7.53.0/lib'
Makefile:893: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

I'm not sure if this /usr/include/openssl/ui.h header should be used when curl is configured to build with boringssl, it seems this file only exists in OpenSSL, not boringssl.

user3340499
  • 189
  • 1
  • 10

1 Answers1

12

There's no openssl/ui.h in the boringssl tree, your build clearly found another set of include files (plain OpenSSL I'd guess).

This is how I build with boringssl:

build boringssl

$HOME/src is where I put the code in this example. You can pick wherever you like.

$ cd $HOME/src
$ git clone https://boringssl.googlesource.com/boringssl
$ cd boringssl
$ mkdir build
$ cd build
$ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on ..
$ make

set up the build tree to get detected by curl's configure

In the boringssl source tree root, make sure there's a lib and an include dir. The lib dir should contain the two libs (I make them symlinks into the build dir). The include dir is already present by default. Make and populate lib like this (commands issued in the source tree root, not in the build/ subdirectory).

$ mkdir lib
$ cd lib
$ ln -s ../build/ssl/libssl.a
$ ln -s ../build/crypto/libcrypto.a

configure curl

LIBS=-lpthread ./configure --with-ssl=$HOME/src/boringssl (where I point out the root of the boringssl tree)

verify that at the end of the configure run, it should say it detected BoringSSL to be used

build curl

run make in the curl source tree

Now you can install curl normally with make install etc.

Stalinko
  • 3,319
  • 28
  • 31
Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
  • Thanks for the help. There was no `lib` dir after building boringssl, so I made `lib` a symlink to `build` (although this only contains one lib, libgtest.a). Which are the two libs which I should put in the `lib` dir? The configure run ending with: checking for ssl with RSAglue/rsaref libs in use... checking for SSL_connect in -lssl... (cached) no no configure: error: OpenSSL libs and/or directories were not found where specified! – user3340499 Feb 22 '17 at 14:56
  • Worked great, thanks a lot! This works perfect. (maybe that `cmake ..` should be `cmake .`, I had to `cd` in to `build` to run `cmake ..`) – user3340499 Feb 23 '17 at 12:54
  • Thank you for these instructions @Daniel Stenberg, I was able to compile `curl` with BoringSSL with the help. I had to make an alteration to the `cmake` portion to be `cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on ..` instead. I'm not an expert at linux / compiling apps, so I didn't want to update your answer in case it's bad advice. – Matthew Dec 13 '19 at 14:52
  • Tried to compile the latest cURL with BoringSSL and nghttp2 by this instruction. Can't `make` cURL because of this error: `/usr/bin/ld: /tmp/boringssl/lib/libcrypto.a(bcm.c.o): relocation R_X86_64_PC32 against symbol 'stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC`. Any ideas how to deal with it? @Matthew isn't it the reason why you added `DCMAKE_POSITION_INDEPENDENT_CODE=on`? @Daniel-Stenberg ? – Stalinko Feb 08 '22 at 12:36
  • Solution has been found on github: https://github.com/curl/curl/issues/8416 . I've updated the answer accordingly. – Stalinko Feb 11 '22 at 06:56