FAQ
I successfully built a node add-on on windows using Visual Studio.
Now I want to build the same add-on on windows but targeting Linux.

1. Is it possible to compile a node c++ add-on on windows for Linux?
2. What compiler should I install on windows?
3. Would it be possible using node-gyp?


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

  • Mscdex at Oct 28, 2012 at 1:57 pm

    On Oct 28, 9:31 am, NodeNinja wrote:
    I successfully built a node add-on on windows using Visual Studio.
    Now I want to build the same add-on on windows but targeting Linux.
    It's probably going to be easier to just create a linux VM for
    compiling/testing purposes.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • NodeNinja at Oct 28, 2012 at 5:15 pm


    It's probably going to be easier to just create a linux VM for
    compiling/testing purposes.
    I had seen a few binding.gyp scripts with lines like these

    'conditions': [
    ['OS=="linux"',

    ['OS=="mac"',

    ['OS=="win"',

    ]

    and was wondering if there was anyway to target multiple platforms?




    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Mscdex at Oct 28, 2012 at 5:37 pm

    On Oct 28, 1:15 pm, NodeNinja wrote:
    and was wondering if there was anyway to target multiple platforms?
    Sure, you can target multiple platforms in your binding.gyp easily
    using conditionals like that. However I thought you were originally
    asking how to compile a Linux executable on Windows.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • NodeNinja at Oct 29, 2012 at 3:35 am

    On Sunday, October 28, 2012 11:07:48 PM UTC+5:30, mscdex wrote:
    On Oct 28, 1:15 pm, NodeNinja wrote:
    and was wondering if there was anyway to target multiple platforms?
    Sure, you can target multiple platforms in your binding.gyp easily
    using conditionals like that. However I thought you were originally
    asking how to compile a Linux executable on Windows.
    My intention in to build the addon on one system preferably having Windows
    OS and then use that addon on Windows and Linux.
    If I do something like this in binding.gyp
    'conditions': [
    ['OS=="linux"',

    ['OS=="mac"',

    ['OS=="win"',

    ]
    and then building the addon on windows?

    1. Will three versions of the addon be generated?
    2. Can I then run the addon on Windows and Linux?

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Ben Noordhuis at Oct 29, 2012 at 1:15 pm

    On Mon, Oct 29, 2012 at 4:30 AM, NodeNinja wrote:
    On Sunday, October 28, 2012 11:07:48 PM UTC+5:30, mscdex wrote:
    On Oct 28, 1:15 pm, NodeNinja wrote:
    and was wondering if there was anyway to target multiple platforms?
    Sure, you can target multiple platforms in your binding.gyp easily
    using conditionals like that. However I thought you were originally
    asking how to compile a Linux executable on Windows.

    My intention in to build the addon on one system preferably having Windows
    OS and then use that addon on Windows and Linux.
    If I do something like this in binding.gyp
    'conditions': [
    ['OS=="linux"',

    ['OS=="mac"',

    ['OS=="win"',

    ]
    and then building the addon on windows?

    1. Will three versions of the addon be generated?
    No. You need to run the node-gyp configure/build cycle once for each
    platform that you target. Here is how you approximately would script
    that on a UNIX system:

    for OS in linux mac win; do
    GYP_DEFINES="-DOS=$OS" CC=gcc-$OS CXX=g++-$OS node-gyp rebuild --arch=ia32
    cp build/Release/module.node build/Release/module-$OS.node
    done

    CC and CXX need to point to the cross-compilers for the platform that
    you're compiling for. If your module is C++ only, you can skip the CC
    variable.
    2. Can I then run the addon on Windows and Linux?
    Provided you get everything to compile, yes. :-)

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • NodeNinja at Oct 30, 2012 at 3:47 am

    No. You need to run the node-gyp configure/build cycle once for each
    platform that you target. Here is how you approximately would script
    that on a UNIX system:

    That was great news Ben,
    Since I am doing this on a Windows system What cross compiler would you
    recommend to target Unix/Linux, gcc or MinGW?


    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Mscdex at Oct 30, 2012 at 4:39 am

    On Oct 29, 11:47 pm, NodeNinja wrote:
    Since I am doing this on a Windows system What cross compiler would you
    recommend to target Unix/Linux,  gcc or MinGW?
    I recommend setting up and using a local Linux virtual machine if you
    do not have access to a Linux system elsewhere.

    You might be able to get away with using a cross-compiler under
    cygwin, but just mentioning that makes me cringe.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • NodeNinja at Nov 1, 2012 at 4:01 am

    I recommend setting up and using a local Linux virtual machine if you
    do not have access to a Linux system elsewhere.

    You might be able to get away with using a cross-compiler under
    cygwin, but just mentioning that makes me cringe.
    Your advice is sound mscdex...
    I couldn't find much info on the net for cross compiling on windows
    possibly install linux on a vm is a good way to start!


    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • Jonathan Kunkee at Nov 2, 2012 at 6:00 am

    You might be able to get away with using a cross-compiler under
    cygwin, but just mentioning that makes me cringe.
    Your advice is sound mscdex...
    I couldn't find much info on the net for cross compiling on windows
    possibly install linux on a vm is a good way to start!
    Yeah...that is theoretically possible, but good luck getting libc to
    match, let alone your other bindings, architectures, etc.

    NodeNinja:

    Note that having a module that will hapilly 'npm install' on all three OSes
    does NOT require pre-building them. The Gyp scripting you saw does exactly
    that: it detects which OS it's building on and follows different
    instructions for each. Testing all three, on the other hand...I second
    mscdex' vote for using a virtual machine to test in a native environment. :)

    If you're looking at an embedded system, you *might* want to cross-compile
    the module down to a binary on a different machine, at which point you have
    stepped into a different arena from simply building something that will
    compile and run successfully across platforms. (I'd stick it out for native
    compilation; YMMV.)

    Good luck!
    --Jon

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en
  • NodeNinja at Nov 3, 2012 at 6:09 am
    NodeNinja:
    Note that having a module that will hapilly 'npm install' on all three
    OSes does NOT require pre-building them. The Gyp scripting you saw does
    exactly that: it detects which OS it's building on and follows different
    instructions for each. Testing all three, on the other hand...I second
    mscdex' vote for using a virtual machine to test in a native environment. :)

    Good luck!
    --Jon
    Excellent Info Jonathan, the part that modules don't necessarily need to be
    pre built with the node-gyp system almost skipped me.

    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedOct 28, '12 at 1:31p
activeNov 3, '12 at 6:09a
posts11
users4
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase