Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nw js node-java build issues #5960

Closed
AnnamrajuSarvani opened this issue Jun 12, 2017 · 11 comments
Closed

nw js node-java build issues #5960

AnnamrajuSarvani opened this issue Jun 12, 2017 · 11 comments
Assignees
Labels

Comments

@AnnamrajuSarvani
Copy link

Hi,
I am getting version issues I am using nw 0.22.3 and tried lower nw versions but I get above error. Node: 6.10.3, java: jdk 1.8.0 and jre 1.8.0
The module '/home/cronj-10/Sarvani/offline-sample-app-new/node_modules/java/build/Release/nodejavabridge_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 51.

I re-compiled with nw-gyp build --target=nw-version(0.22.3)
My node-java version 0.8.0.
What is issue in building? How to fix this?
I am using ubuntu14.04

@Christywl
Copy link
Contributor

could you please provide a sample and steps to reproduce it?

@AnnamrajuSarvani
Copy link
Author

Hi,
I have python 2.7 and java 1.8 on ubuntu 14.04. I installed node java 0.80 with npm install.
After install I did node-gyp build it work fine with node build. As I am building nw js application for above steps I did nw-gyp build and it fails there says make failed -ljvm not found.
After start my application with nw I get below error:
The module '/home/cronj-10/Sarvani/offline-sample-app-new/node_modules/java/build/Release/nodejavabridge_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 51.
Current I am using nw 0.22.3
Is it a version issue? what do I do for this?

@Christywl
Copy link
Contributor

It works well on my ubuntu 16.04 with nwjs-sdk-v0.22.3 after I do nw-gyp rebuild --target=0.22.3.
My steps:

  • npm install java
  • create a js file named test.js:
var java = require('java');
var javaLangSystem = java.import('java.lang.System');
javaLangSystem.out.printlnSync('Hello World');
  • node test.js--->Pass
  • create package.json and index.html(<script src="test.js"></script>) for nwjs
  • start the nw app ---> NODE_MODULE_VERSION errors occur
  • cd node_module/java, do nw-gyp rebuild --target=0.23.2 and node postInstall.js
  • start the nw app again ---> Pass

@Christywl
Copy link
Contributor

@rogerwang , I find another issue, this doesn't work for nwjs v0.23.2.
Error: /bin/sh: 1: ./build/linux/sysroot_ld_path.sh: not found, is this a nwjs issue or nw-gyp issue?

When I do nw-gyp rebuild --target=0.23.2, some errors occur:

lei@lei-dev:~/00_lei/nwjs/bugs/5960/0.23.2/node_modules/java$ nw-gyp rebuild --target=0.23.2
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@6.10.0 | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/nw-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/lei/00_lei/nwjs/bugs/5960/0.23.2/node_modules/java/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/nw-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/lei/.nw-gyp/0.23.2/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/lei/.nw-gyp/0.23.2',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/nw-gyp',
gyp info spawn args   '-Dnode_lib_file=nw.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/lei/00_lei/nwjs/bugs/5960/0.23.2/node_modules/java',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '-Dv13=1',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
/bin/sh: 1: ./build/linux/sysroot_ld_path.sh: not found
gyp: Call to './build/linux/sysroot_ld_path.sh /home/lei/00_lei/nwjs/bugs/5960/0.23.2/node_modules/java/build/linux/debian_jessie_amd64-sysroot' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/nw-gyp/lib/configure.js:324:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-79-generic
gyp ERR! command "/home/lei/tools/node-v6.10.0-linux-x64/bin/node" "/usr/local/bin/nw-gyp" "rebuild" "--target=0.23.2"
gyp ERR! cwd /home/lei/00_lei/nwjs/bugs/5960/0.23.2/node_modules/java
gyp ERR! node -v v6.10.0
gyp ERR! nw-gyp -v v3.4.0
gyp ERR! not ok

@AnnamrajuSarvani
Copy link
Author

AnnamrajuSarvani commented Jun 14, 2017

I am getting this build issue in ubuntu14.04
../src/utils.cpp:354:33: warning: ‘v8::Localv8::Number v8::Value::ToNumber() const’ is deprecated (declared at /home/cronj-10/.nw-gyp/0.22.2/deps/v8/include/v8.h:9304): Use maybe version [-Wdeprecated-declarations]
jdouble val = arg->ToNumber()->Value();
^
SOLINK_MODULE(target) Release/obj.target/nodejavabridge_bindings.node
/usr/bin/ld: cannot find -ljvm
collect2: error: ld returned 1 exit status
make: *** [Release/obj.target/nodejavabridge_bindings.node] Error 1
make: Leaving directory /home/cronj-10/Sarvani/offline-sample-app/node_modules/java/build' gyp ERR! build error gyp ERR! stack Error: make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/cronj-10/.nvm/versions/node/v5.11.0/lib/node_modules/nw-gyp/lib/build.js:294:23)
gyp ERR! stack at emitTwo (events.js:100:13)
gyp ERR! stack at ChildProcess.emit (events.js:185:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 3.13.0-115-generic
gyp ERR! command "/home/cronj-10/.nvm/versions/node/v5.11.0/bin/node" "/home/cronj-10/.nvm/versions/node/v5.11.0/bin/nw-gyp" "rebuild" "--target=0.22.2"
gyp ERR! cwd /home/cronj-10/Sarvani/offline-sample-app/node_modules/java
gyp ERR! node -v v5.11.0
gyp ERR! nw-gyp -v v3.4.0
gyp ERR! not ok
I am not sure of it from where is the exact issue but node-gyp build works.

@swhgoon
Copy link
Contributor

swhgoon commented Jun 14, 2017

@Christywl
Same Error: /bin/sh: 1: ./build/linux/sysroot_ld_path.sh: not found

locate at file ~/.nw-gyp/0.23.2/config.gypi

      ['OS=="linux" and target_arch=="x64"', {
        'sysroot': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_jessie_amd64-sysroot',
      }],

@Asp3ctus
Copy link

@swhgoon thanks for your comment.
I have edited file ~/.nw-gyp/0.23.2/common.gypi
removed
['OS=="linux" and target_arch=="x64"', { 'sysroot': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_jessie_amd64-sysroot', }],
and replaced
[ 'target_arch=="x64"', { 'cflags': [ '-m64', '--sysroot=<(sysroot)' ], 'ldflags': [ '-m64', '--sysroot=<(sysroot)','<!(<(DEPTH)/build/linux/sysroot_ld_path.sh <(sysroot))' ], }],
with
[ 'target_arch=="x64"', { 'cflags': [ '-m64' ], 'ldflags': [ '-m64' ], }],

and my module succesfuly builded

@saboya
Copy link

saboya commented Jun 24, 2017

So, I wrote a 1-liner to handle this issue for now. Just run this pior to npm install:

mkdir -p ~/.nw-gyp/0.23.4 && wget http://node-webkit.s3.amazonaws.com/v0.23.4/nw-headers-v0.23.4.tar.gz && tar -xzvf ./nw-headers-v0.23.4.tar.gz -C ~/.nw-gyp/0.23.4 --strip-components=1 && echo 9 > ~/.nw-gyp/0.23.4/installVersion && patch -u ~/.nw-gyp/0.23.4/common.gypi ./linux-build.patch

The file linux-build.patch does what @Asp3ctus described:

--- common.gypi.old	2017-06-23 20:07:53.288437686 -0300
+++ common.gypi	2017-06-23 20:09:26.616549237 -0300
@@ -52,9 +52,6 @@
       ['OS=="linux" and target_arch=="ia32"', {
         'sysroot': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_jessie_i386-sysroot',
       }],
-      ['OS=="linux" and target_arch=="x64"', {
-        'sysroot': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_jessie_amd64-sysroot',
-      }],
       ['OS== "mac"', {
         'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
         #'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
@@ -401,8 +398,8 @@
             'ldflags': [ '-mx32' ],
           }],
           [ 'target_arch=="x64"', {
-            'cflags': [ '-m64', '--sysroot=<(sysroot)' ],
-            'ldflags': [ '-m64', '--sysroot=<(sysroot)','<!(<(DEPTH)/build/linux/sysroot_ld_path.sh <(sysroot))' ],
+            'cflags': [ '-m64' ],
+            'ldflags': [ '-m64' ],
           }],
           [ 'target_arch=="ppc" and OS!="aix"', {
             'cflags': [ '-m32' ],

Obviously this assumes you're using v0.23.4, if you want a different version just make the appropriate changes.

hujiajie added a commit to hujiajie/chromium.src that referenced this issue Aug 23, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for current problems.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Aug 23, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for current problems.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Aug 25, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
@chlp
Copy link

chlp commented Aug 29, 2017

@Klemen1337, hello! You wrote TryGhost/node-sqlite3#852 (comment):

Fixed with this #5960

Can you write here a link to commit?

hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 1, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 19, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 20, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 20, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 21, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 21, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Sep 25, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
hujiajie added a commit to hujiajie/chromium.src that referenced this issue Oct 9, 2017
This is an ongoing rework of toolchain selection for building Node.js.

See nwjs/nw.js#5960 and nwjs/nw.js#5971 for why previous integration can
lead to trouble.
@sulthonzh
Copy link

hi, all, Is problem fixed?

i can't install this

npm install https://github.com/mapbox/node-sqlite3/tarball/master --build-from-source --runtime=node-webkit --target_arch=x64 --target=0.26.5

@rogerwang rogerwang self-assigned this Nov 10, 2017
@rogerwang rogerwang added bug and removed needinfo labels Nov 10, 2017
@rogerwang
Copy link
Member

This is fixed in git and will be available in 0.26.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants