port a node addon from node-waf to node-gyp

158 views
Skip to first unread message

NodeNinja

unread,
Sep 26, 2012, 12:01:00 PM9/26/12
to nod...@googlegroups.com
I am trying to build this  https://github.com/substack/node-bigint module on linux
I was previously built with node-waf but I am trying to build it with node-gyp to use in on the most recent versions of node.

I have a bindings.gyp file as under.

{
  "targets": [
{
 "target_name": "bigint",
 "sources": [ "bigint.cc" ]
}
]
}

However with this file the module builds successfuly but I don't think it is linked to libgmp that it needs to function correctly.
How do link libgmp to that module.

I have installed gmp5.0.5 on my linux system but I don't seem to find it in usr/bin; usr/local/bin etc.


Ben Noordhuis

unread,
Sep 26, 2012, 12:13:46 PM9/26/12
to nod...@googlegroups.com
'libraries': ['-lgmp'] should do it.

NodeNinja

unread,
Sep 26, 2012, 12:54:23 PM9/26/12
to nod...@googlegroups.com

'libraries': ['-lgmp'] should do it.

That seems to work out my updated binding.gyp is as under

{
  "targets": [
{
 "target_name": "bigint",
 "sources": [ "bigint.cc" ],
                  "libraries": ["-lgmp"]
}
]
}

However when I check the size of the final compiled "bigint.node" file it is showing much lower size that previous builds

node-waf linux      - 204kb with libgmp
node-gyp on win   - 274kb   with mpir instead of libgmp
node-gyp on linux - 58Kb with libgmp 

Is libgmp being dynamically linked to bigint or am I messing up somewhere else?

mscdex

unread,
Sep 26, 2012, 2:40:57 PM9/26/12
to nodejs
On Sep 26, 12:54 pm, NodeNinja <aeon6f...@gmail.com> wrote:
> Is libgmp being dynamically linked to bigint or am I messing up somewhere
> else?

Yes it should be dynamically linked now. You can double check by doing
`ldd /path/to/binding.node`.

NodeNinja

unread,
Sep 26, 2012, 3:11:22 PM9/26/12
to nod...@googlegroups.com

On Thursday, September 27, 2012 12:11:08 AM UTC+5:30, mscdex wrote:

Yes it should be dynamically linked now. You can double check by doing
`ldd /path/to/binding.node`.

I think you meant `ldd /path/to/bigint.node`. 

and it prints out:

linux-gate.so.1 (0xb779f000)
libgmp.so.10 => /usr/lib/libgmp.so.10 (0xb7722000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb763a000)
libm.so.6 => /usr/lib/libm.so.6 (0xb75fa000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xb75dd000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0xb75c2000)
libc.so.6 => /usr/lib/libc.so.6 (0xb7416000)
/usr/lib/ld-linux.so.2 (0xb77a0000) 


Not that I understand what this means but since its printing out libgmp at some places seems like its linked to it.
Don't understand what the so.1 or so.6 is though...

mscdex

unread,
Sep 26, 2012, 4:56:50 PM9/26/12
to nodejs
On Sep 26, 3:11 pm, NodeNinja <aeon6f...@gmail.com> wrote:
> libgmp.so.10 => /usr/lib/libgmp.so.10 (0xb7722000)

This means it is dynamically linking to libgmp. So you should be good
to go.
Reply all
Reply to author
Forward
0 new messages