Hey there Barry,

> The problem comes in when I try incorporate the scrypt into a Node addon.
> Note that scrypt is a C library. Whenever I call the scrypt function, it
> always results in a segmentation fault. I traced the error to the function
> `SHA256_Update`. It is defined by the scrypt author, yet it is not being
> called. I guess it is being linked to another `SHA256_Update` function, and
> hence the `SHA256_Update` that the author wrote is not being called.

So it *does* look like that function gets exported in the node
executable. I'm assuming this comes from OpenSSL, which gets
statically linked to the binary:

  $ nm `which node` | grep SHA256_Update
  00000001000df69f T _SHA256_Update

> I have heard about node_g, yet I can't find any source to obtain it. Please
> can someone tell me where to get it?

You must compile a "debug" build of node:

  $ configure --debug && make

After that it will be in the root of the node source code directory.

> Scrypt is authored in C, so should I create a `static_library` in gyp, or
> should I compile it together with my main addon file.

Personally, I'd recommend writing a dedicated gyp file for the scrypt
library (so using "static_library"). I wrote a blog article detailing
how to do this: http://n8.io/converting-a-c-library-to-gyp/

> I am forced to wrap my header file for scrypt in `extern "c"` for correctly
> linking. This is correct, isn't it?

Not *totally* positive but I believe this is correct. Ben or someone
else can probably clarify.

> How can I ensure that the correct `SHA256_Update` is executed. And if this
> is not being executed, what is?

So this is kinda the tough problem right? Since you have control over
the scrypt code at this point, you could rename that particular
function since it seems to be incompatible with the SHA256_Update in
the node binary. Again, one of the more experienced C guys can
probably come up with a better solution for that particular problem.

Cheers!

-- 
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