mmomtchev / magickwand.js

Full native ImageMagick-7 bindings for Node.js native & WASM - showcase for SWIG Node-API
ISC License
49 stars 6 forks source link

Failed download nodejs & cant find /swig #202

Closed Xheldon closed 1 month ago

Xheldon commented 1 month ago

First of all, this is an amazing project. Thank you very much for your open-source contribution!

Secondly, let me explain what I want to do. I am building an Electron application using Electron-forge. The purpose of the application is to handle a handful of image formats, such as conversion, compression, etc., and ultimately distribute it to my users (for free). Because I need to handle HEIC format images, I ruled out the sharp library and chose Magickwand.js.

However, to my frustration, even after downloading the so-called "static" binaries into my project (either magickwand.node or executable binaries on MacOS arm64 M1 Max chip), it still fails to find the x11 dynamic library (and perhaps other libraries too) when running. I used the otool -L command to check the binary, and it does show dynamic links to multiple software limited to my local homebrew installation.

Since I only need to handle a limited number of common image formats, including: png, jpg, webp, tiff, heic (that's all), and none of the other features, I decided to compile a version from scratch on my machine using the Magickwand.js source code you provided.

My build script is as follows:

npm install --build-from-source --verbose --foreground-scripts           \
  --disable-fonts --disable-shared --enable-jpeg --enable-png --enable-tiff                   \
  --enable-webp --enable-jpeg2000 --disable-raw --disable-openmedia         \
  --disable-exr --disable-fftw --enable-heif \
  --disable-color --disable-xml --disable-gzip --disable-zip                   \
  --disable-bzip2 --disable-zstd --disable-xz --disable-lzma --disable-simd   \
  --disable-openmp --disable-display --disable-jbig --disable-cairo

, but it always gets stuck on the following error:

meson.build:18:7: ERROR: Failed downloading from https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)>

I followed solutions online, setting up openssl or running the install Certificates.command for python in the system, but the issue still persists.

Sorry, I am purely a web developer and know nothing about C, C++, and compilation systems. However, after asking OpenAI, I found that xpack contains specific versions of Python, which might be why modifying the system's Python cannot solve the problem.

So I created a new issue here and look forward to your response. Any replies regarding solving the issue of 「using magick to process HEIC images in Electron」 would be greatly appreciated. Thank you in advance!

fmeson-logs.txt

Build started at 2024-07-31T17:48:11.385386
Main binary: /Users/user/Developer/test-magick-src/xpacks/.bin/python
Build Options: -Dprefix=/Users/user/Developer/test-magick-src/lib/binding/darwin-arm64 -Dbackend=ninja -Dbuildtype=release --native-file=hadron/conan.ini --native-file=hadron/system-darwin.ini --native-file=build/native/conan_meson_native.ini
Python system: Darwin
The Meson build system
Version: 1.5.1
Source dir: /Users/user/Developer/test-magick-src
Build dir: /Users/user/Developer/test-magick-src/build/native
Build type: native build
Project name: JavaScript bindings for ImageMagick-7
Project version: 2.0.0-rc.5
-----------
Detecting compiler via: `clang --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c -E -dM -
pre-processor extraction using -cpp -x c failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/user/Developer/test-magick-src/build/native/meson-private/sanitycheckc.exe
C compiler for the host machine: clang (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C linker for the host machine: clang ld64 1053.12
-----------
Detecting archiver via: `llvm-ar-15 --version` -> [Errno 2] No such file or directory: 'llvm-ar-15'
-----------
Detecting archiver via: `llvm-ar --version` -> [Errno 2] No such file or directory: 'llvm-ar'
-----------
Detecting archiver via: `ar --version` -> 1
stderr:
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
-----------
-----------
Detecting compiler via: `clang++ --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c++ -E -dM -
pre-processor extraction using -cpp -x c++ failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang++ -Wl,--version -stdlib=libc++` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang++ -Wl,-v -stdlib=libc++` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C++ compiler: clang++
Is cross compiler: False.
Sanity check compiler command line: clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe -stdlib=libc++
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/user/Developer/test-magick-src/build/native/meson-private/sanitycheckcpp.exe
C++ compiler for the host machine: clang++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C++ linker for the host machine: clang++ ld64 1053.12
-----------
Detecting compiler via: `clang --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c -E -dM -
pre-processor extraction using -cpp -x c failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/user/Developer/test-magick-src/build/native/meson-private/sanitycheckc.exe
C compiler for the build machine: clang (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C linker for the build machine: clang ld64 1053.12
-----------
Detecting archiver via: `llvm-ar-15 --version` -> [Errno 2] No such file or directory: 'llvm-ar-15'
-----------
Detecting archiver via: `llvm-ar --version` -> [Errno 2] No such file or directory: 'llvm-ar'
-----------
Detecting archiver via: `ar --version` -> 1
stderr:
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
-----------
-----------
Detecting compiler via: `clang++ --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c++ -E -dM -
pre-processor extraction using -cpp -x c++ failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang++ -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang++ -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C++ compiler: clang++
Is cross compiler: False.
Sanity check compiler command line: clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/user/Developer/test-magick-src/build/native/meson-private/sanitycheckcpp.exe
C++ compiler for the build machine: clang++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C++ linker for the build machine: clang++ ld64 1053.12
Build machine cpu family: aarch64
Build machine cpu: aarch64
Host machine cpu family: aarch64
Host machine cpu: aarch64
Target machine cpu family: aarch64
Target machine cpu: aarch64

meson.build:18:7: ERROR: Failed downloading from https://nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz: 

mmomtchev commented 1 month ago

Does

python3 -c 'import urllib.request; print(urllib.request.urlopen("https://google.com").read())'

work on your installation?

mmomtchev commented 1 month ago

Also what does

which openssl
openssl version -d

say?

Xheldon commented 1 month ago

Thank you for the quick reply!

After switching to a clean M1 chip computer, the problem disappeared, and nodejs seems to be able to download properly, so please ignore my previous issue.

However, a new problem has arisen. After downloading node, executing swig-related content prompts that the file cannot be found. I went through the issues and found that you seem to have changed the build output from /build to /swig before, but I don't see that directory in the project now. Did I miss something?

By the way, I cloned the project with git clone --recursive https://github.com/mmomtchev/magickwand.js .

Error log(again)

Build started at 2024-08-01T00:39:47.411387
Main binary: /Users/x/Developer/test-magick-src/xpacks/.bin/python
Build Options: -Dprefix=/Users/x/Developer/test-magick-src/lib/binding/darwin-arm64 -Dbackend=ninja -Dbuildtype=release --native-file=hadron/conan.ini --native-file=hadron/system-darwin.ini --native-file=build/native/conan_meson_native.ini
Python system: Darwin
The Meson build system
Version: 1.5.1
Source dir: /Users/x/Developer/test-magick-src
Build dir: /Users/x/Developer/test-magick-src/build/native
Build type: native build
Project name: JavaScript bindings for ImageMagick-7
Project version: 2.0.0-rc.5
-----------
Detecting compiler via: `clang --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c -E -dM -
pre-processor extraction using -cpp -x c failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/x/Developer/test-magick-src/build/native/meson-private/sanitycheckc.exe
C compiler for the host machine: clang (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C linker for the host machine: clang ld64 1053.12
-----------
Detecting archiver via: `llvm-ar-15 --version` -> [Errno 2] No such file or directory: 'llvm-ar-15'
-----------
Detecting archiver via: `llvm-ar --version` -> [Errno 2] No such file or directory: 'llvm-ar'
-----------
Detecting archiver via: `ar --version` -> 1
stderr:
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
-----------
-----------
Detecting compiler via: `clang++ --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c++ -E -dM -
pre-processor extraction using -cpp -x c++ failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang++ -Wl,--version -stdlib=libc++` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang++ -Wl,-v -stdlib=libc++` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C++ compiler: clang++
Is cross compiler: False.
Sanity check compiler command line: clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe -stdlib=libc++
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/x/Developer/test-magick-src/build/native/meson-private/sanitycheckcpp.exe
C++ compiler for the host machine: clang++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C++ linker for the host machine: clang++ ld64 1053.12
-----------
Detecting compiler via: `clang --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c -E -dM -
pre-processor extraction using -cpp -x c failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C compiler: clang
Is cross compiler: False.
Sanity check compiler command line: clang sanitycheckc.c -o sanitycheckc.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/x/Developer/test-magick-src/build/native/meson-private/sanitycheckc.exe
C compiler for the build machine: clang (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C linker for the build machine: clang ld64 1053.12
-----------
Detecting archiver via: `llvm-ar-15 --version` -> [Errno 2] No such file or directory: 'llvm-ar-15'
-----------
Detecting archiver via: `llvm-ar --version` -> [Errno 2] No such file or directory: 'llvm-ar'
-----------
Detecting archiver via: `ar --version` -> 1
stderr:
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]
-----------
-----------
Detecting compiler via: `clang++ --version` -> 0
stdout:
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-----------
Running command: -cpp -x c++ -E -dM -
pre-processor extraction using -cpp -x c++ failed, falling back w/o lang
Running command: -E -dM -
-----
-----------
Detecting linker via: `clang++ -Wl,--version` -> 1
stderr:
ld: unknown options: --version 
clang: error: linker command failed with exit code 1 (use -v to see invocation)
-----------
-----------
Detecting Apple linker via: `clang++ -Wl,-v` -> 0
stderr:
@(#)PROGRAM:ld PROJECT:ld-1053.12
BUILD 10:15:51 Mar 29 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
-----------
Sanity testing C++ compiler: clang++
Is cross compiler: False.
Sanity check compiler command line: clang++ sanitycheckcpp.cc -o sanitycheckcpp.exe
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command:  /Users/x/Developer/test-magick-src/build/native/meson-private/sanitycheckcpp.exe
C++ compiler for the build machine: clang++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C++ linker for the build machine: clang++ ld64 1053.12
Build machine cpu family: aarch64
Build machine cpu: aarch64
Host machine cpu family: aarch64
Host machine cpu: aarch64
Target machine cpu family: aarch64
Target machine cpu: aarch64
Node.js library distribution:  /Users/x/Library/Caches/node-hadron/node/v18.19.0
Running command: /Users/x/.nvm/versions/node/v18.19.0/bin/node -p 'fs.readdirSync("/Users/x/Developer/test-magick-src/swig").filter(x => x.match(/cxx$/)).map((x) => `swig/${x}`).join(",")'
--- stdout ---

--- stderr ---
node:internal/fs/utils:351
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '/Users/x/Developer/test-magick-src/swig'
    at Object.readdirSync (node:fs:1525:3)
    at [eval]:1:4
    at Script.runInThisContext (node:vm:122:12)
    at Object.runInThisContext (node:vm:298:38)
    at node:internal/process/execution:82:21
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:81:62)
    at evalScript (node:internal/process/execution:103:10)
    at node:internal/main/eval_string:30:3 {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: '/Users/x/Developer/test-magick-src/swig'
}

Node.js v18.19.0

meson.build:35:10: ERROR: Command `/Users/x/.nvm/versions/node/v18.19.0/bin/node -p 'fs.readdirSync("/Users/x/Developer/test-magick-src/swig").filter(x => x.match(/cxx$/)).map((x) => `swig/${x}`).join(",")'` failed with status 1.


dir shotscreen:

CleanShot_2024_08_01_at_00_53_27@2x

Thank you!

Xheldon commented 1 month ago

Does

python3 -c 'import urllib.request; print(urllib.request.urlopen("https://google.com").read())'

work on your installation?

Also what does

which openssl
openssl version -d

say?

To inform future people of potential similar issues, I will explain the result of executing this command on this computer when nodejs is properly acquired:

python3 -c 'import urllib.request; print(urllib.request.urlopen("https://google.com").read())'

Successfully retrieved HTML content.

and

which openssl output: /opt/homebrew/anaconda3/bin/openssl openssl version -d output: OPENSSLDIR: "/opt/homebrew/anaconda3/ssl"

mmomtchev commented 1 month ago

If you checkout the source tree from git you will need SWIG JSE 5.0.4 to regenerate the wrappers.

If you are rebuilding the npm package, the SWIG generated wrappers are already included.

It is a little bit like configure.ac and configure - configure is usually not committed to git but it is included in release tarballs.

Xheldon commented 1 month ago

Thank you very much for your suggestion!

From the output, I have successfully run -—build-from-source(the cmd i mention above).

Now, to integrate this into my Electron application, do I just need to move everything from the lib directory and index.cjs under native into my Electron app directory? Or, do I just need the lib/binding/darwin-arm64/magickwand.node file (I noticed it's quite large)?

While I noticed that the main field in package.json points to native, and index.mjs under native uses /swig/magickwand-js.cjs, I don't need the .mjs re-export so I ignored it.

Thanks again!

mmomtchev commented 1 month ago

hadron does not support Electron yet. Electron requires to rebuild with its own headers and libraries.

mmomtchev commented 1 month ago

You can use the WASM version which should work without any additional setup.

Xheldon commented 1 month ago

I directly placed the file lib/binding/darwin-arm64/magickwand.node into my Electron application and required it, and it worked well. Of course, this might be because I haven't packaged and distributed it to my users yet, so maybe it only works on my machine?

Also, you suggest that I use the WASM version directly. Should I download the emscripten-wasm32.tar.gz file from this directory https://github.com/mmomtchev/magickwand.js/releases, extract it to get the three files, including one .wasm and two corresponding .mjs files, and integrate them into Electron?

Thanks for the reply!

mmomtchev commented 1 month ago

You might have problems, including crashes, because the node-api of Electron is slightly different - for example it does not support creating a Buffer without copying. Generally, you need to rebuild with the Electron headers. It is a special option for node-gyp that hasn't yet been implemented in hadron.

Xheldon commented 1 month ago

You might have problems, including crashes, because the node-api of Electron is slightly different - for example it does not support creating a Buffer without copying. Generally, you need to rebuild with the Electron headers. It is a special option for node-gyp that hasn't yet been implemented in hadron.

Thank you for your suggestion. At the current stage, I'll try using WASM first. Thanks!