Code Monkey home page Code Monkey logo

Comments (11)

sehz avatar sehz commented on June 26, 2024 1

@simlay Please take look at this

from node-bindgen.

vmoroz avatar vmoroz commented on June 26, 2024 1

Though, now that I look at the node repo, it looks like napi_module_register is soon to be deprecated but napi_define_properties isn't.

Please note that while we consider simplification of Node-API module registration and stopping use of napi_module_register, we do not remove any existing API functions. To keep the ABI compatibility this function will be there for a long time.

from node-bindgen.

jdoig avatar jdoig commented on June 26, 2024 1

Ok this is utterly embarrassing 😳 ... The function I was wanting to expose had it's

#[node_bindgen()]

commented out.

One interesting issue with this is:
Now I have un-commented that line everything works ... as long as I don't have a build.rs as soon as I add it back into the project I get exactly the same error as before 😕

from node-bindgen.

jdoig avatar jdoig commented on June 26, 2024 1

This is still causing problems:

  1. node_bindgen::build::configure(); in build.rs causes it not to build (though looking at the code that configure should noop on Linux right?) with the initial error.
  2. If I remove that line from the build.rs both cargo and nj-cli can build my library ... BUT cargo test fails with the initial error.

So I can now build my node binary and it all seems to be working form inside a node session ... I just cant run my unit tests.

Update: To rule out any weirdness in my local terminal session I started up a fresh Debian Docker container: apt installed nodejs and gcc, then installed rust through rustup-init.sh ... same results, I can build but cant test 😕

Update: I also have tried compiling the node-bindgen examples with the same issues.

Update: I'm not sure if it's at all relevant but I've also tried compiling Neon examples and they compile fine and test fine with no linking issues.

Update: Just had a colleague with an M2 Mac try this with similar results. Can cargo build cant cargo test the /examples folder of this repo without getting linking errors:

 param git:(master) cargo test
   Compiling nj-example-param v0.0.0 (/Users/xxx/node-bindgen/examples/param)
    Finished test [unoptimized + debuginfo] target(s) in 0.28s
     Running unittests src/lib.rs (/Users/xxx/node-bindgen/examples/target/debug/deps/nj_example_param-67c9517494263fc8)
dyld[80564]: symbol not found in flat namespace (_napi_create_int32)
error: test failed, to rerun pass '--lib'

Caused by:
  process didn't exit successfully: `/Users/xxx/node-bindgen/examples/target/debug/deps/nj_example_param-67c9517494263fc8` (signal: 6, SIGABRT: process abort signal)

(he got the same error when he did pass the --lib flag too)

from node-bindgen.

sehz avatar sehz commented on June 26, 2024

Can you provide OS, Rust, and other information to debug this?

from node-bindgen.

jdoig avatar jdoig commented on June 26, 2024

Can you provide OS, Rust, and other information to debug this?

Sorry 🤦 , of course @sehz :
OS:

NAME="Pop!_OS"
VERSION="22.04 LTS"

Rust (I've tried with both of these:

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu

I've tried compiling with node-bindgen 4.3 and 5 but get the same errors.

from node-bindgen.

simlay avatar simlay commented on June 26, 2024

Hmm. This looks to be related to how the nj-core is linked to node at completive. @jdoig What's your nodejs setup like? Like, I'm using fnm to manage which nodejs I'm using and this builds with node 14 (as that's what a project I work on sometimes uses).

Though, now that I look at the node repo, it looks like napi_module_register is soon to be deprecated but napi_define_properties isn't.

from node-bindgen.

jdoig avatar jdoig commented on June 26, 2024

@simlay
My node setup is very much that of someone who's a node novice/hobbyist . My current goal is to port some of our auth' code over to a rust library I can call from Python/Node/etc for our other developers. So that we have ve a single uniformed auth library with strong typing and good error handling. Node isn't my runtime of choice 😄

Typically I've node 14/16/18 installed and controlled via nvm. And now, to follow your setup I've also installed fnm and tired this using: 14/18/system versions of node though fnm` ... all with the same error still 😞

I've checked my gcc, make and python versions against Node's toolchain requirements.

And here's some "clutching-at-straws" steps I've taken 😆 :

  • I have libffi and libffi-dev installed on my machine already.
  • I've installed node-gyp, node-ffi (based on some searches for node ffi tools and libraries).
  • Used cmake-js install to: Install Node.js distribution files if needed.

But still the same problem.

from node-bindgen.

yannleretaille avatar yannleretaille commented on June 26, 2024

I can confirm as I ran into the same issue:

  • Arch Linux (kernel 6.2.12)
  • node v19.9.0 from extra/nodejs
  • rust 1.71-nightly
  • build.rs:
    fn main() {
        node_bindgen::build::configure();
    }
    
  • Cargo.toml
    [package]
    name = "project-name"
    edition = "2021"
    
    [lib]
    crate-type = ["cdylib"]
    
    [dependencies]
    node-bindgen = { version = "5.1" }
    
    [...]
    
    [build-dependencies]
    node-bindgen = { version = "5.1", default-features = false, features = ["build"]}
    

Results in this error:

> ~/.cargo/bin/nj-cli build -o dist 
  |
  = note: LC_ALL="C" PATH="~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:~/.cargo/bin:~/.local/bin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "cc" "-m64" "/tmp/rustcHYSVpD/symbols.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.1u26bdjqvo8hjbno.rcgu.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.484c40cyeng6z092.rcgu.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.g1afhabpyeyft7b.rcgu.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.pzta0jecpcl93jf.rcgu.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.qt7jpx7nnsf9p38.rcgu.o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e.1xta2omldd5rwbqj.rcgu.o" "-Wl,--as-needed" "-L" "~/project-folder/target/debug/deps" "-L" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "~/project-folder/target/debug/deps/libnode_bindgen-72f039e41aead63a.rlib" "~/project-folder/target/debug/deps/libnj_build-1aaf22f736cb42df.rlib" [...] "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-35b8a4bd2de4e62e.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "~/project-folder/target/debug/build/project-name-c045ed565816713e/build_script_build-c045ed565816713e" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: ~/project-folder/target/debug/deps/libnj_core-aaa6e789a8145b4c.rlib(nj_core-aaa6e789a8145b4c.nj_core.8b52fda313818e30-cgu.14.rcgu.o): in function `nj_core::module::init_module':
          ~/.cargo/git/checkouts/node-bindgen-48597ec4d5b120bf/dba17af/nj-core/src/module.rs:90: undefined reference to `napi_module_register'
          /usr/bin/ld: ~/project-folder/target/debug/deps/libnj_core-aaa6e789a8145b4c.rlib(nj_core-aaa6e789a8145b4c.nj_core.8b52fda313818e30-cgu.0.rcgu.o): in function `nj_core::basic::JsExports::define_property':
          ~/.cargo/git/checkouts/node-bindgen-48597ec4d5b120bf/dba17af/nj-core/src/basic.rs:963: undefined reference to `napi_define_properties'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `project-name` (build script) due to previous error

Removing/Uncommenting the node_bindgen::build::configure() line in build.rs fixes the issue and the project builds correctly.

from node-bindgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.