On Mon, Oct 29, 2012 at 4:30 AM, NodeNinja <[email protected]> wrote:
>
> On Sunday, October 28, 2012 11:07:48 PM UTC+5:30, mscdex wrote:
>>
>> On Oct 28, 1:15 pm, NodeNinja <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to