node.lib

450 views
Skip to first unread message

Pawel Por

unread,
Apr 14, 2014, 10:32:25 AM4/14/14
to nod...@googlegroups.com
Hi

I can see that node.lib exists in Windows installation and does not exist in Linux one.
It is used when linking native (C++) modules. I wonder why node.lib is not necessary during linking on Linux.
Is everything what is inside node.lib included in ~/.node-gyp/0.10.26/deps/v8/include and ~/.node-gyp/0.10.26/deps/uv/include under Linux ?
If so why it isn't done this way under Windows.

thanks for explanation

mscdex

unread,
Apr 14, 2014, 11:14:14 AM4/14/14
to nod...@googlegroups.com
On Monday, April 14, 2014 10:32:25 AM UTC-4, Pawel Por wrote:
I can see that node.lib exists in Windows installation and does not exist in Linux one.
It is used when linking native (C++) modules. I wonder why node.lib is not necessary during linking on Linux.

It's a matter of platform differences. AFAIK Windows' shared libraries (DLLs) are more like regular executables, just without a main entry point. So because of this, the linker needs to know some extra information (e.g. names and entry points) of functions inside the DLL in order for an external program to be able to link to and call those functions. This information is what is stored inside the .lib file.

On *nix however, a shared library already contains all of the necessary information needed for linking to it, so no extra (.lib) file is needed.

That is why a .lib is needed for Windows and not for Linux :-)

Kevin Ingwersen

unread,
Apr 14, 2014, 12:11:38 PM4/14/14
to nod...@googlegroups.com
Good to know this one! :)
Always good to read about the differences of unix and win32 stuff. :)
--



Pawel Por

unread,
Apr 15, 2014, 4:27:49 AM4/15/14
to nod...@googlegroups.com

Thanx for reply to all of you, but the question is still open.
Why there is no "node like" library to link under Linux, or at least I can't see it when building a native module under Linux using node-gyp.
I'm using verbose parameter with node-gyp and I can see the exact g++ line used to link my native module.
In this process I cannot see any nodejs specific library that it is linked with.
I also cannot see any nodejs specific library when listing shared library dependencies with ldd my_module.node
 

mscdex

unread,
Apr 15, 2014, 1:37:01 PM4/15/14
to nod...@googlegroups.com
On Tuesday, April 15, 2014 4:27:49 AM UTC-4, Pawel Por wrote:
 also cannot see any nodejs specific library when listing shared library dependencies with ldd my_module.node
 

In the case of node.js bindings/addons, they are compiled as standalone shared libraries and are then loaded by node via dlopen on *nix or LoadLibraryExW on Windows when you require() the .node file.

Pawel Por

unread,
Apr 17, 2014, 10:42:55 AM4/17/14
to nod...@googlegroups.com

Thanks for your patience but I still don't understand one thing. Why there is something node specific (I mean node.lib) required to link addon under windows while there is nothing node specific required to link the addon under Linux ?

Sam Roberts

unread,
Apr 22, 2014, 3:42:32 PM4/22/14
to nod...@googlegroups.com
On Thu, Apr 17, 2014 at 7:42 AM, Pawel Por <porp...@gmail.com> wrote:
> Thanks for your patience but I still don't understand one thing. Why there
> is something node specific (I mean node.lib) required to link addon under
> windows while there is nothing node specific required to link the addon
> under Linux ?

Because they are different operating systems, with completely
different linker file formats.
Reply all
Reply to author
Forward
0 new messages