I'm currently writing a node-webkit application which uses a native module (lwip). I found out that I need to compile native modules with nw-gyp.
After using nw-gyp a new file lwip_image.node will be created under node_modules/lwip/build/Release.
How is the native module required? Like this: var lwip_image = require('./node_modules/lwip/build/Release/lwip_image.node') ??
If the native module was created on Win8 x64, will it also work on Win7 x64 or even Win8/7 x32? Same question for Mac vs Ubuntu x32 vs Ubuntu x64?
To facilitate the build process I would build the native modules on the target platforms once. After that I would like to copy them all to my project dir so I can automate the build process to build it for all platforms at once. How would I go about that? Use os.platform() and require depending on platform? ...
UPDATE: Those posts were what I was looking for: https://github.com/joyent/node/issues/4398#issuecomment-11233144
https://github.com/npm/npm/issues/1891
Your module's short name will be used in "require"
Your 32-bit code (compiled with target=ia32) will work on 64-bit platform, but not the other way around
After you have compiled your module for all platforms, it should be enough to pack different zip, .app or .exe versions for different platforms, with different respective binaries of your module.
Related
I've created an electron application which uses two NodeJS native modules node ref and node ffi. The application is being developed on windows right now and the windows executable is generated with the help of electron-builder. This all works perfectly fine and the application is installed in windows properly. As both ffi and ref are native modules, I'm simply use electron-rebuild to rebuild them for platform win32 (I guess that internally uses node-gyp).
But the problem is, my CI/CD server is Ubuntu 16 and I need to generate the windows executable file there. If my application doesn't have node's native addons, it works fantastic but with native modules included, the exe file is generated but on launch it says %1 is not a win32 application and the reason for that is, the native deps are rebuilt for Linux platform instead of windows.
So I wanted to know is, is there any way to rebuild the node native modules on Linux machine for win32 platform or if its not possible then how can we use the pre-built .node file across the platforms.
If I use a Node native addon in an Electron app that will be used on Mac and Windows, do I need to do anything special to ensure that the correct flavor of the add-on (Mac or Windows) is used in each build? I'm developing on Windows, but users will also be running on Mac. I'll build the output with Electron-Builder.
Thanks.
I'm using node webkit with the node webkit hipster seed
I have build a native C++ module, using the Leap Motion SDK, which compile and work fine with node-gyp.
Now I'm trying to implement it on node webkit, but I always get "Error: no error" when I require my module. (Yes, it's recompiled with nw-gyp)
I was getting the same error when I was trying my module with node-gyp without leap sdk dlls, so I try to move my dlls in the module build directory, and in the application build directory, but no effect.
I'm using Windows 8, but I will also build on OSx
Strangely, it work by renamming the executable to nw.exe, thanks to https://github.com/geo8bit/nodebob/pull/7
I developed an app via TideSDK on OSX. I have a .app and It is working on OSX. However, you know it cannot work on linux or windows. I want to run my app on linux or windows. How can I do that?
In short, you package for each platform. As you are aware mac apps do not run on Windows and it is the same with TideSDK since you are creating something native for each platform.
TideSDK must be installed on each platform to create an executable and bundle for it.
To generate an installer for each system, you need to run commands on each system (windows / linux 32bit / linux 64bit) using tidebuilder.py on the command line.
We will have more to speak about concerning packaging quite soon that will make the task of building and distributing your apps easier. Stay tuned for updates !!
Will I have to use the crosstool that cygwin provides to make the libX11.so, libGL.so, and libGLU.so libraries using their respective source code? Or do you know where I can find them compiled already for crosstool (I'm new to this cross compilation)?
Just for clarification: I'm on a windows 7 machine trying to get my application also to compile for linux systems by using cygwin's cross compilation. The application uses OpenGL. Thanks
To cross-compile for Linux you should install the needed development libs and headers on a linux box[1] and then copy /usr/lib and /usr/include your cygwin environment (e.g. /crosscompiler/linux/...). When you build the cross compiler in cygwin, tell it where those native linux headers and libs are so they'll be used when you compile your app.
[1] If you're looking to run on a wide variety of linux boxes make sure you pick an older linux distro (e.g. Red Hat 9) to ensure your app doesn't have dependencies on very new glibc, etc..
Why do you want to use Cygwin?
There is instructions on the OpenGL Wiki about how to use OpenGL on Windows using MinGW.
MinGW use the same GNU tools that are available on Linux (GCC, GDB, GMAKE, etc.) but produce Windows native executables. So, you shouldn't have trouble compiling your source code on both platforms.
I just ended up building on a native Linux machine.