1

I have a problem regarding binding jq library using node-gyp.

I have 2 node-gyp files

  1. for building the nan code
  2. for building the JQ code

You can see the full repo in here https://github.com/danielsinai/jq-node-bindings.git

I'm getting the error while trying to run the following program (index.js):

const jq = require('bindings')('jq-node-bindings');

console.log(jq)

const x =  jq.exec(JSON.stringify({ foo: 'bar' }), '.foo');

console.log(x)

The error:

node: symbol lookup error: /root/code/jq-bindings/build/Release/jq-node-bindings.node: undefined symbol: _Z7jq_init

nm command output

 nm -g build/deps/libjq.so.1 | grep jq_init
000000000003acb0 T jq_init

ldd command output

ldd /root/code/jq-bindings/build/Release/jq-node-bindings.node
        linux-vdso.so.1 (0x00007ffe0bbf0000)
        libjq.so.1 => /root/code/jq-bindings/build/Release/../deps/libjq.so.1 (0x00007feb84541000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007feb84316000)
        libm.so.6 => /lib64/libm.so.6 (0x00007feb8423b000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007feb84220000)
        libc.so.6 => /lib64/libc.so.6 (0x00007feb84017000)
        /lib64/ld-linux-x86-64.so.2 (0x00007feb84630000)
Mor Paz
  • 2,088
  • 2
  • 20
  • 38
Daniel Sinai
  • 136
  • 7

1 Answers1

0

Solved, missing the extern keyword as I was running cpp code against c module hope it will help someone in the futrue

extern "C" {
    #include "jq.h"
    #include "jv.h"
}
Daniel Sinai
  • 136
  • 7