I have the following structure:
~/Desktop/hellonode$ ls
build rs232.h testnode.js helloworld.cc helloworld.node rs232.c
and in rs232.h
:
int OpenComport(int, int);
But when I try to create a node native plugin and use the following code:
#include "rs232.h"
using namespace v8;
void init(Handle<Object> target) {
int cport_nr=0; /* /dev/ttyS0 (COM1 on windows) */
if(OpenComport(cport_nr, bdrate))
{
printf("Can not open comport\n");
return;
}
target->Set(String::NewSymbol("hello"),
FunctionTemplate::New(Method)->GetFunction());
}
I build the plugin using node-waf
Everything compiles fine, however, when I try running it I get the following error:
~/Desktop/hellonode$ node testnode
node: symbol lookup error: <~>/Desktop/hellonode/build/Release/helloworld.node: undefined symbol: OpenComport
This is a link error, not a compiler error. Is OpenComport
defined in rs232.c
, and are you linking rs232.c
into your executable?