node-datachannel: Fail to install on Ubuntu 22 LTS

Ubuntu 22.04.2 LTS (GNU/Linux 5.19.0-1025-aws aarch64) Node v19.9.0

npm ERR! code 137
npm ERR! path /home/ubuntu/node_modules/node-datachannel
npm ERR! command failed
npm ERR! command sh -c prebuild-install || (npm install --ignore-scripts --production=false && npm run _prebuild)
npm ERR! prebuild-install WARN install libcrypto.so.1.1: cannot open shared object file: No such file or directory
npm ERR! npm WARN config production Use `--omit=dev` instead.
npm ERR! Killed

But when I run

openssl version

yields

OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

Why do I need openssl-1.1.1 ?

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 1
  • Comments: 21 (10 by maintainers)

Most upvoted comments

We have 2 different situations/problems here. Let’s divide this into 2 issues to not cause confusion.

Mac M1 OpenSSL static build - #229

Linux arm64 OpenSSL static build - #230

Could you please follow up there?

$> ldd node_datachannel.node This command should also give the dynamic library list on Mac.

This is the result for linux. It must be something like that.

murat@murat-ThinkBook:~/js/node-datachannel/build/Release$ ldd node_datachannel.node 
        linux-vdso.so.1 (0x00007fffa1b15000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8756a00000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f8757861000)

I tried to build it with actions, it also built somehow 😃

Could you please check the result and actions? https://github.com/murat-dogan/node-datachannel/actions

Could you download the binary and test it? https://github.com/murat-dogan/node-datachannel/releases/tag/v0.5.6-dev

@SgtPooki Thank you.

What I see from logs is you have OpenSSL v3 installed. So It will build also with it happily.

-- Found OpenSSL: /opt/homebrew/Cellar/openssl@3/3.2.1/lib/libcrypto.dylib (found suitable version "3.2.1", minimum required is "1.1.0")  
-- Found PCAP: pcap  
-- Found OpenSSL: /opt/homebrew/Cellar/openssl@3/3.2.1/lib/libcrypto.dylib (found version "3.2.1")  

But the problem is we are building it as dynamically linked against OpenSSL. From cmake file we need to modify these lines (as you did); https://github.com/murat-dogan/node-datachannel/blob/a07715d4a13c89e1a79b0bad54b2490beb999ce5/CMakeLists.txt#L27-L30

To be sure I created a new branch with required changes. So Just clone the branch and try to build it.

https://github.com/murat-dogan/node-datachannel/tree/arm64-static-openssl

This is github ci file I am using; https://github.com/murat-dogan/node-datachannel/blob/arm64-static-openssl/.github/workflows/build-mac-m1.yml

I dont have a arm64 PC so I can not test more. If anyone can find a solution for that I will be happy to merge it.

@murat-dogan i’d be interested in helping figure out a way to not fallback to openssl1.1 for M1 builds. Can you guide me a little bit on what the process would look like?

I cloned the repo and ran npm i && npm run build and things build fine locally. Attached are build and test logs:

build-log.txt test-log.txt

I modified CMakeLists.txt as follows:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f29c3b..ed2b086 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,10 +24,10 @@ endif()
 # /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: ../sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha1-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
 # ../sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha1-armv8.o): in function `sha1_block_armv8':
 # (.text+0x1240): dangerous relocation: unsupported relocation
-if(NOT ${NODE_ARCH} STREQUAL "arm64")
-    set(OPENSSL_USE_STATIC_LIBS TRUE)
-    find_package(OpenSSL REQUIRED)
-endif()
+#if(NOT ${NODE_ARCH} STREQUAL "arm64")
+set(OPENSSL_USE_STATIC_LIBS TRUE)
+find_package(OpenSSL REQUIRED)
+#endif()

 include(FetchContent)

and got the following build log output with rm -rf build prebuilds tmp && npm run build &> build-log-edited.txt. it seems to build fine?

build-log-edited.txt

I’m happy to help if you have time to provide some guidance 😃

Hello,

As I replied here https://github.com/murat-dogan/node-datachannel/issues/178#issuecomment-1688914544; For arm64 openssl linked as a shared library. Unfortunately we need the right version to run.

Please Check here; https://github.com/murat-dogan/node-datachannel/blob/c8197e28b39fd81f55818c0301995414fa877ff9/CMakeLists.txt#L27

I dont have a arm64 PC so I can not test more. If anyone can find a solution for that I will be happy to merge it.