On Fri, Mar 15, 2013 at 3:27 PM, Benjamin Farrell <[email protected]> wrote:
> Hey everyone,
> This group's help got me up and running with my first Node.js AddOn a couple
> months back, I'm pretty excited that all this stuff is working.  But now
> that I have something stable, I realize that my C++ code is a little
> disorganized and I should really start breaking out what I can into separate
> files or classes as I continue.
>
> I'm having a pretty big problem doing this, though.  I thought the problem
> was solely C++ oriented, but the more I look around and ask people, it
> sounds like I'm doing the right thing, and it might be specific to my
> project or just Node compilation in general.
>
> So the problem is this - I broke out functionality into another class.  I
> did it the proper way, and put the method signatures into a .h file and the
> actual methods into a .cpp file.
>
> I then, of course, include the .h file in my main project.   It all compiles
> fine, but then when running the addon, I get:
>
> /usr/local/bin/node: symbol lookup error:
> ../node_modules/nuimotion/src/build/Release/nuimotion.node: undefined
> symbol: _ZN11EnumMapping15mapEventToLabelEi
>
> Where EnumMapping is my class and mapEventToLabel is a method within.
>
> Also weird is that I can write gibberish into my cpp file that obviously
> would never compile, but it does.  So obviously it seems that my cpp file
> isn't being referenced, only the h file is being compiled in.
>
> So, this is where I'm at.  I feels like any other weird C++ problem, but
> everyone I talk to tell me that all they ever have to do is include the .h
> file and it works, but they aren't working on Node addons - and that's why
> I'm writing here...in case there's something Node/V8 specific.
>
> Perhaps I'm missing a fundamental piece of information being a beginner c++
> person.  I see people using externs, templates, etc, and admittedly I don't
> really understand those concepts yet.  I'm just using a plain .h file like
> so:
>
> class EnumMapping
> {
> public:
> Local<String> mapEventToLabel(int event);
> Local<String> mapGeneralEventToLabel(int event);
> Local<String> mapGestureToLabel(int event);
> Local<String> mapErrorToLabel(int event);
> }
>
> And then my .cpp file takes the structure like so:
>
> #include "../enums/EnumMapping.h"
>
> Local<String> EnumMapping::mapEventToLabel(int event) {
>    ...function body
> }
>
> ...other methods...
>
> Again, sorry if this isn't a Node specific problem, but I hope you can help!
>
> thanks!

It sounds like you forgot to add the .cc file to the 'sources' section
in your bindings.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 [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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to