Ok, stuck again. Got everything working with the integer and pointer thing from all the help before (thanks!) but now I'm stuck in another place. The source files I have are .C files with .H headers. I can compile them using node-gyp with no issues and apparently bind them to my .CC file with no issue.
When I try and actually USE them though I get back an error saying undefined symbol: <somevalue> where <somevalue> is always _Z11<methodName>v the _Z11 and v never changes. The <methodName> part is always the name of the method from the .C file.
I'm guessing this is something really simple, but I don't know enough about C/CC/whatever to know where I'm screwing up.
Here is a simple example, while this isn't the real code it blows up just like the real code :)
/* lib.c */
#include lib.h
int test_linked(void){
return 1;
}
/* lib.h */
#ifndef _LIB_
#define _LIB_
int rest_linked(void);
#endif
/*lib.cc*/
#include <node.h>
#include <v8.h>
#include "lib.h"
using namespace v8;
Handle<Value> Test(const Arguments& args){
HandleScope scope;
return scope.Close(Number::New(test_linked()));
}
void init(Handle<Object> exports) {
exports->Set(String::NewSymbol("test"),
FunctionTemplate::New(Test)->GetFunction());
}
NODE_MODULE(lib, init)
/* binding.gyp */
{
"targets": [
{
"target_name": "lib",
"sources": [
"src/lib.c",
"src/lib.cc"
]
}
]
}
Building with node-gyp rebuild results in all proper .O files put where you would expect (build/Release/obj.target/lib/src) and the .NODE file going where it should (build/Release)
Then using:
var lib = require('./build/Release/lib');
lib.test();
Fails with:
node: symbol lookup error: /home/.../build/Release/lib.node: undefined symbol: _Z11test_linkedv
I know this is something I'd doing wrong, but not sure what. I'm guessing there is some reference to the .O files missing or they are where they shouldn't be so when the .NODE file loads it can't find the .O files and thus can't link the methods.
As always, any help greatly appreciated.
- Jeremy