infinyon / node-bindgen

Easy way to write Node.js module using Rust
Apache License 2.0
527 stars 44 forks source link

Build issue on Linux #271

Closed SteveMcFarlin closed 12 months ago

SteveMcFarlin commented 12 months ago

This issue is exactly the same as #195. On MacOS my build works fine, but on Linux it does not within my project. The node-bindgen examples will compile and run just fine on Linux. I will look over the PR that solved the prior issue report, and see if I can fix this. Let me know if you need any further information, or would like me to try anything.

  = note: /usr/bin/ld: /home/streamer/dev/sy/rendition-rs/target/debug/deps/libnj_core-f9ac5f82c386df13.rlib(nj_core-f9ac5f82c386df13.nj_core.a5f48bd5f6c1e6c7-cgu.2.rcgu.o): in function `nj_core::module::init_module':
          /home/streamer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nj-core-6.0.0/src/module.rs:87: undefined reference to `napi_module_register'
          /usr/bin/ld: /home/streamer/dev/sy/rendition-rs/target/debug/deps/libnj_core-f9ac5f82c386df13.rlib(nj_core-f9ac5f82c386df13.nj_core.a5f48bd5f6c1e6c7-cgu.0.rcgu.o): in function `nj_core::basic::JsExports::define_property':
          /home/streamer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nj-core-6.0.0/src/basic.rs:929: undefined reference to `napi_define_properties'
          collect2: error: ld returned 1 exit status

Linux: Pop!_OS 22.04 LTS Rust Version: rustc 1.73.0 (cc66ad468 2023-10-03) Node Version: v16.16.0 node-bindgen: 6.0.1 build command: nj-cli build -- --lib --features="node-bindgen"

Cargo.toml

[package]
name = "rendition"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]
name = "rendition"
path = "src/lib.rs"

[[bin]]
name = "rendition"
path = "src/bin/rendition.rs"

# Enable this feature when build the node-bindgen based lib.
[features]
node-bindgen = []

[dev-dependencies]
reqwest = "0.11.11"
serial_test = "*"
tracing-test = { version = "0.2.4", features = ["no-env-filter"] }

[build-dependencies]
node-bindgen = { version = "6.0.1", features = ["build"] }

[dependencies]
anyhow = "1.0.68"
async-std = { version = "1.7", features = ["unstable"] }
async-trait = "0.1.57"
axum = "0.6.2"
clap = "2.33"
crossbeam-channel = "0.5.6"
eyre = "0.6.5"
futures-util = "0.3.17"
gstreamer = "0.19.5"
gstreamer-video = "0.16"
node-bindgen = "6.0.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0.38"
tokio = { version = "1.22", features = ["full"] }
tokio-stream = "0.1"
tokio-test = "0.4.2"
tokio-tungstenite = "*"
toml = "0.7.3"
tower = { version = "0.4", features = ["full"] }
tower-http = { version = "0.3.5", features = ["fs"] }
tracing = "0.1.37"
tracing-futures = "0.2"
tracing-gstreamer = "0.5.0"
tracing-log = "0.1.2"
tracing-subscriber = { version = "0.3.16", features = ["json", "env-filter"] }
tracing-tracy = "0.10.2"
xcb = "1.2.0"
SteveMcFarlin commented 12 months ago

After reading the old issue and linked fix, taking a look at the examples again, I fixed it simply by adding default-features = false to the node-bindgen build-dependency

[build-dependencies]
node-bindgen = { version = "6.0.1", default-features = false, features = [
  "build",
] }

I believe I copied the build dep for cargo from the README.md while I was initially setting up the project and working on MacOS.