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

libnode.so for 32 bit is missing #4

Open
dominictarr opened this issue Jul 30, 2017 · 23 comments
Open

libnode.so for 32 bit is missing #4

dominictarr opened this issue Jul 30, 2017 · 23 comments

Comments

@dominictarr
Copy link

okay it looks like I got it installed, it says it built successfully, but when I tried to run it on my phone I got this error:

Error:error: '../../../../src/main/jniLibs/armeabi-v7a/libnode.so', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', missing and no known rule to make it

I'm trying to figure out where libnode.so comes from?
okay, a bit of searching led me here: nodejs/node#14158

gonna check that out...

btw, I changed line 14 of app/build.gradle to

abiFilters 'armeabi-v7a', 'arm64-v8a'
@dominictarr
Copy link
Author

do I have to build libnode.so or can I download it from somewhere?

@dominictarr
Copy link
Author

dominictarr commented Jul 30, 2017

hmm, so node has an android-configure script, with this comment at the top:

# In order to cross-compile node for Android using NDK, run:
#   source android-configure <path_to_ndk> [arch]
#
# By running android-configure with source, will allow environment variables to
# be persistent in current session. This is useful for installing native node
# modules with npm. Also, don't forget to set the arch in npm config using
# 'npm config set arch=<arch>'

so this seemed to work:

./android-configure ~/android-sdk/ndk-bundle/ arm --shared

remember to include "--shared" so that it becomes a shared object

@simonhochrein
Copy link

It looks like 32-bit is not supported currently.

@Seanmclem
Copy link

It says only ARM64

@mafintosh
Copy link
Collaborator

@dominictarr did it compile? Would be super helpful if you could share the shared lib with me so I can package this up so we dont need android studio. Here is how I compiled in Termux otherwise

Building Node.js as a shared library in Termux

Install deps

pkg install git python2 #and the compilers

Clone the node repo

git clone git://github.com/nodejs/node.git
cd node
git checkout v8.2.1

Configure

python configure --without-snapshot --openssl-no-asm --shared --dest-os=android

Then in deps/cares/config/android/ares_config.h comment out

#define HAVE_GETSERVBYPORT_R 1

And run make (will take a while). Remember to have Termux aquire a wake lock so your phone doesnt go to sleep

Shared lib is out/Release/lib.target/libnode.so.57

@dominictarr
Copy link
Author

oh yeah @mafintosh okay i'll try that.

@dominictarr
Copy link
Author

wow, node's git repo is 1.9gb!

@dominictarr
Copy link
Author

I managed to get it on my phone with 20 something mb to spare... not sure if this will work to be honest...

@ralphtheninja
Copy link

Maybe you could use curl instead to skip the complete history, e.g.

$ curl -sL https://github.com/nodejs/node/archive/v8.2.1.tar.gz > node.tar.gz

@ralphtheninja
Copy link

Or use --depth with git clone

$ git clone --depth=2 -b v8.x https://github.com/nodejs/node.git

@dominictarr
Copy link
Author

@ralphtheninja I tried a shallow clone and it didn't work because first it clones it into .git then it checks it out which uses double. In the end what I did was local clone on my laptop to _node, then tar -c _node | ssh android@... tar -x which extracts it inplace without first placing the tar file on disk! it's now compiling in screen.

@dominictarr
Copy link
Author

actually my phone has 20 gb available, but not within the linux container, and not sure how to fix that.

@dominictarr
Copy link
Author

I left it going overnight, and it ended with this error:

/usr/bin/ld: cannot find -llog
collect2: error: ld returned 1 exit status
deps/openssl/openssl-cli.target.mk:195: recipe for target '/home/android/_node/out/Release/openssl-cli' failed
make[1]: *** [/home/android/_node/out/Release/openssl-cli] Error 1
rm 100e139f03cb0d4f87114c8730081b12e85b3487.intermediate
Makefile:76: recipe for target 'node' failed
make: *** [node] Error 2

hmm, okay, so it can't find a library... liblog? is this part of node? I'm guessing that there are probably way more errors like this behind it

@aschrijver
Copy link

@dominictarr Did you manage to build the 32bit library?

I've been trying many different things with ndk build, but always run into errors somewhere. My latest try is even with a r17 ndk canary build: nodejs/node#14771

@dominictarr
Copy link
Author

I didn't get passed that one. @mafintosh said he was gonna try on his rpi, but havn't heard back about that yet.

@aschrijver
Copy link

I created a number of NodeJS issues on building for android. Hopefully will result in a solution.

Meantime I am looking at J2V8 who have a very nice cross-compile build system PR based on Docker and Vagrant in the works and almost ready to be merged: eclipsesource/J2V8#327

PS Found this to be helpful script addition:

# see # see https://github.com/nodejs/node/issues/3074
sed -i 's/#define HAVE_GETSERVBYPORT_R 1/#undef HAVE_GETSERVBYPORT_R/' deps/cares/config/android/ares_config.h 

@aschrijver
Copy link

I spent yesterday compiling and trying different options. My findings are documented on stackoverflow: - Viable options to running NodeJS on Android (Aug 2017)

@aschrijver
Copy link

aschrijver commented Aug 13, 2017

I can make successful builds of 7.4.0 and 7.9.0 (max.) as a static libnode.a included in libj2v8.so. Will now try other node versions. If you just perform the nodejs build step and tweak the script a bit, this might work from you laptop to create a libnode.so.

Update: Probably not that simple. When running only the nodejs build step and --shared in the configure setting gives errors..

@chrisekelley
Copy link
Contributor

Hi - I managed to compile a version of node (from master - 9.0.0?) on a Samsung Galaxyy Tab A SM-T280 tablet running Android 5.1.1 Cortex A7 CPU - it is armeabi-v7a, compiled via termux.

Here is my commit with the shared lib if anyone needs it. I followed @mafintosh's steps to create the node shared lib.

bunsenbrowser/cordova-node-plugin@bb89690

I haven't been able to test it correctly - I think I also may need to make the other shared lib - libc++_shared.so - but haven't had a chance to figure out that process.

Thanks a lot to @mafintosh for leading the way for node on android and to @aschrijver for his perseverence and extremely useful list of the many ways to try to compile node on android.

Here are my notes - they are based on the steps @mafintosh made above:

https://github.com/node-on-mobile/node-on-android/issues/4#issuecomment-318919220

pkg install git python2
apt install clang clang++ g++
pkg install make
pkg install zip
downloaded zip of node from https://github.com/nodejs/node/archive/master.zip
cd /usr/bin
ln -s python2 python

Configure

python configure --without-snapshot --openssl-no-asm --shared --dest-os=android
Then in deps/cares/config/android/ares_config.h comment out

#define HAVE_GETSERVBYPORT_R 1
And run make (will take a while). Remember to have Termux aquire a wake lock so your phone doesnt go to sleep

Shared lib is out/Release/lib.target/libnode.so.57

@aschrijver
Copy link

@chrisekelley thank you, i am honoured :)

sorry for the late response. i am building my new tech startup called innercircles
a non-profit movement for people that care about world and happiness 😃

i expect to pick up the thread sometime later and persevere some more, ha ha :)

you keep rocking!

@avaer
Copy link

avaer commented Jan 12, 2018

I don't know about 32 bit lib builds, but I got the procedure for 64 bit ones working with only minimal changes to node 9.4.0: https://github.com/modulesio/node-android-lib

This presumes you have a real Android 64 device to do it on. I haven't tried emulators.

@mario6714
Copy link

mario6714 commented Jun 18, 2023

Hi, any help for create libnode.so using the most recent node in android? Thanks

This not work for my:

@dominictarr did it compile? Would be super helpful if you could share the shared lib with me so I can package this up so we dont need android studio. Here is how I compiled in Termux otherwise

Building Node.js as a shared library in Termux

Install deps

pkg install git python2 #and the compilers

Clone the node repo

git clone git://github.com/nodejs/node.git
cd node
git checkout v8.2.1

Configure

python configure --without-snapshot --openssl-no-asm --shared --des

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

No branches or pull requests

10 participants