Removing OpenSSL 3.0 devel so C++ compiles on Linux

Viewed 90

I'm on Ubuntu 22.04 and compiling this C++ Github pull request:

https://github.com/ftexchange/ftx/pull/13

However, the PR contains a compile error.

Somebody posted to fix the error OpenSSL 3.0 devel version must be "removed":

It seems like the compiler was using OpenSSL 3.0 devel version, I had to remove that

How do I achieve this?

1 Answers

This is what I did on Ubuntu 22.04 LTS.

$ sudo apt install libboost-dev libssl-dev
$ git clone --recursive --branch openssl-1.1 https://github.com/arf-labs-ou/ftx.git
$ cmake -G Ninja -S ftx/cpp -B build -DCMAKE_BUILD_TYPE=Release
$ cmake --build build

Trying to build at this point will trip deprecation warnings when compiling against the system OpenSSL 3. But because ftx has done the extremely inadvisable thing of hard-coding -Werror in their build, this is promoted to a spurious error. Deprecated doesn't mean "won't work today"; it means "upstream must fix". You are not upstream, so this ought not affect you, but, alas, low-quality build code is not a great surprise.

We will hack around this by wrapping the compiler with a shell script that deletes warning flags from the command line. Create a file called no-warnings.sh:

#!/bin/bash

ARGS=()

for arg in "$@"; do
  if [[ ! "$arg" =~ ^-W ]]; then
    ARGS+=("$arg")
  fi
done

"${ARGS[@]}"

Now let's inject it into the build via the CMAKE_CXX_COMPILER_LAUNCHER hook:

$ chmod +x no-warnings.sh
$ rm -rf build
$ cmake -G Ninja -S ftx/cpp/ -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=$PWD/no-warnings.sh
$ cmake --build build/

This should work but, unfortunately, even this wasn't enough to build successfully. The code itself has a type error! I wonder if something changed between Boost 1.71 and 1.74. Anyway, I applied the following patch:

diff --git a/cpp/src/util/HTTP.cc b/cpp/src/util/HTTP.cc
index 30e0277..2d043f2 100644
--- a/cpp/src/util/HTTP.cc
+++ b/cpp/src/util/HTTP.cc
@@ -100,8 +100,8 @@ void HTTPSession::authenticate(http::request<http::string_body>& req)
     std::string path(req.target());
     std::string body(req.body());
 
-    long ts = get_ms_timestamp(current_time()).count();
-    std::string data = std::to_string(ts) + method + path;
+    auto ts = std::to_string(get_ms_timestamp(current_time()).count());
+    std::string data = ts + method + path;
     if (!body.empty()) {
         data += body;
     }

And now the above commands produce a successful build. The example programs run and produce reasonable output, as well.

Related