-
Notifications
You must be signed in to change notification settings - Fork 24
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
NodeJS 0.11 Port to Android #24
Comments
Yes, I think you need r8b or newer, and build with the 4.6 abi. |
I get an error that it can't find the right ndk arch for macos x86_64. This fixes it.
Of course that would break the non-64bit build then. I'm not sure the correct makefileish way to fix it. After that the build succeeds but the node executable won't run on my rooted device. It says:
I've put libv8.so in the same dir as node and also in /system/usr/lib. 'lib' didn't exist BTW so I had to create it. Also the fs is readonly so I had to do 'adb remount' first to copy the files over. Any ideas how to fix the linking? |
Looks like the libs should go into /system/lib instead of /system/usr/lib |
Whoo hoo!:
|
Fixed the system/lib reference in the wiki, thanks. |
very cool. |
Help, I am getting an error compiling with NDK 8e, V8 compiles fine but when I go back to the node directory, it complains about not finding the correct module in the V8 directory.. This is on a CentOS 64 bit with the X86 NDK installed. [root@localhost node]# cd deps/v8/ |
OK, you're missing a module; I forgot to add that to the instructions. I've updated them - let me know how you get on. |
Now that I have node itself working I want to create a native addon. After reading the wiki I complied the anode hello addon per the instructions and copied it to my device but I can't get it to run. It says the module can't be found. A few questions:
Thanks. This is an awesome project. |
Yes, because that addon makefile expects to be building for the anode implementation, which would be linking against libjninode.so. In this case we just have node, so it needs to link against that. Briefly, you should be able to get it to work by making two changes. Remove the reference to libjninode.so, and add explicit reference to v8:
Allow the addon to link despite not having the required external symbols available:
The environment variable I haven't tried with this node version yet, but this should work. There's potentially an issue with the external visibility of the node symbols but lets see how far we get with this.
Yes. You will do
Yes, sometime around the 0.4 to 0.6 transition, they introduced a new way of declaring the init entrypoint. Node still, to my knowledge, supports both behaviours; you can either just use
The jni stuff serves two purposes - it is involved in getting bridge.node to work, but also provides the jni binding that allows the anode app to load node as a library. Again, this piece isn't migrated to 0.11 yet. For now just ignore both of these.
Yes, it really is |
Wonderful. I had to add the full path to libv8.so and now it works. Interestingly didn't need to turn off UNDEFINED_SYMBOLS actually. Yes, it appears FunctionTemplate was added sometime in the 0.6x timeframe, which was causing the issues. Now I'm building only against the 0.11 node branch and I can get a commandline app to work with native modules. Next up, linking to OpenGL. :) |
You've seen this? https://github.com/paddybyers/node-gl/commits/nodegl I've not tried it on Android. It currently uses GLUT/GLU but I guess not a lot of work to get it to go to EGL. I heard someone got that working but I don't think their code is on github. |
I checked out a copy of openssl, but when I try to run ndk-build root@localhost openssl-android]# ndk-build below is the code at line 512 of _gmsl. Thank you for the quick response. _gmsl @ line 512 Function: int_encode int_encode = |
Is there a reason that the AndroidManifest.xml is empty in the openssl project ? <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:label="@string/app_name"
android:debuggable="true">
</application>
</manifest> The warning I got
|
Simply that, historically, it wasn't needed to build a pure native library with the NDK. I've rebased my changes to the latest version of the original project (https://github.com/guardianproject/openssl-android). Someone fixed the same bug there just a week or so ago. |
Paddy, thank you.. I will update my project. Great projec BTW, t I am having fun hacking node on my cubieboard. Will anode run on a non rooted device since it runs as an APK ? |
Yes. |
|
Yes - this used to happen with the 0.6 version but github removed the downloads feature. Someone else has also talked about investing some effort to get the runtime onto Play.
Yes, on Android you could register the app to handle filetypes or MIME types by default - if there is more than one handler registered for a given type, then the platform asks the user which one to use. |
There's yet another interesting workaround: you could have also started making Actually I dunno if GitHub accepts torrents in repositories, but that seems worth trying. Might be less effort than getting the runtime onto Google Play. |
Hi Paddy, I also tried putting the file hello.node beside the js file and requiring it like: require('./hello.node') and require('./hello') . to be more clear all the attempts above gave me an error of can't load the module except the last one, it didn't give any error but on the same time it didn't execute the function hello() (that exists in hello.cc). Any help will be highly appreciated. |
have you tried putting it into /data/data/org.meshpoint.anode/node_modules/ ? cheers |
@paddybyers did you see this: nodejs#5514 ? |
@feichh no, I hadn't seen that, thanks. I'll have a look at how it compares; I suspect not much different. It's good if we now have the changes landed upstream. |
@paddybyers Since I noticed the reference was added and looked over this, I can give a short rundown on my implementation strategy: Rather than setting up Android.mk files - which have to be maintained separately - I went for the standalone toolchain approach. Documentation is available under docs/standalone-toolchain.html in the NDK. (Random version on the net at https://github.com/flyskywhy/android-ndk-r7b/blob/master/docs/STANDALONE-TOOLCHAIN.html) In short, it provides you with a build environment for android cross-compilation using other toolchains than ndk-build. Based on that, I setup what you normally use for cross-compilation, i.e. exports for CC, LD, AR, etc. and ensure gyp is aware that OS=="android" rather than "linux". To supplement this, I included a configuration script which given an NDK path can setup the cross-compilation environment and configure gyp automatically. From there onwards, the gyp build scripts are used almost as-is, with some configuration details and compatibility issue resolutions added in uv, cares & node to resolve build errors. You see these referenced in the PR. Unless especially build-breaking features are added (such as advanced pthread functionalities that aren't available in android) these patches should be forward-compatible with little maintenance as Node develops. On the flipside, I haven't integrated existing shared objects from android, instead opting to push a statically linked node executable sized at 10MB. Note that this will most likely provide for better binary compatibility over multiple devices, since e.g. libssl and friends are in my experience fragile when it comes to binary compatibility between versions (which will likely cause issues when you want an apk running on G-J releases of android.) This also means some differences when including the project in an apk - I'd probably build it separately and include it in a project as a prebuilt binary - but this is of course heavily project dependent. |
Opening a new issue to discuss build problems with the new 0.11 port.
Following the instructions here:
https://github.com/paddybyers/node/wiki/Building-v0.11-for-Android
I get a compile error.
➜ v8 git:(remotes/origin/v0.11-android) make -j8 GYPFLAGS="-Dcomponent=shared_library" android_arm.debug
Makefile.android:70: *** Cannot find Android toolchain in "/Users/josh/projects/android-sdk-macosx/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86//toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86". Stop.
make: *** [android_arm.debug] Error 2
My install has 4.4.3 instead of 4.6. This implies a newer NDK is required.
The text was updated successfully, but these errors were encountered: