Была поставлена задача:
1) Написать шаред либу на c++
2) Прикрутить эту библиотеку к node.js так, чтобы можно было передавать жавоскриптовые коллбеки внутрь этой библиотеки.
С первым пунктом справился, а со вторым пунктом возникли проблемы.
Что я делал:
1) установил в систему node-gyp(через npm), v8, nodejs из репозиториев
2) Добавил в библиотеке метод
void libgt2d::RunCb(v8::Handle<v8::Context> &context, v8::Persistent<v8::Function> &cb)
{}
0000000000001a0e T _ZN7libgt2d5RunCbERN2v86HandleINS0_7ContextEEERNS0_10PersistentINS0_8FunctionENS0_27NonCopyablePersistentTraitsIS6_EEEE
{
'targets':
[
{
'target_name': 'gt2d',
'sources':
[
'gt2d.cc',
'myobject.cc'
],
'link_settings':
{
'libraries':
[
'-lgt2d',
'-lv8'
]
}
}
]
}
undefined symbol: _ZN7libgt2d5RunCbERN2v86HandleINS0_7ContextEEERNS0_10PersistentINS0_8FunctionEEE
libv8.a: Doesn't exist any more, but you'll find static libraries in out/ia32.release/obj.target/tools/gyp/. Link against those. If your project uses GYP, simply have it depend on the "v8" target and everything will "just work".
g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/home/sm/.node-gyp/0.10.26/src -I/home/sm/.node-gyp/0.10.26/deps/uv/include -I/home/sm/.node-gyp/0.10.26/deps/v8/include -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/gt2d/gt2d.o.d.raw -c -o Release/obj.target/gt2d/gt2d.o ../gt2d.cc
g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/home/sm/.node-gyp/0.10.26/src -I/home/sm/.node-gyp/0.10.26/deps/uv/include -I/home/sm/.node-gyp/0.10.26/deps/v8/include -fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -O2 -fno-strict-aliasing -fno-tree-vrp -fno-omit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF ./Release/.deps/Release/obj.target/gt2d/myobject.o.d.raw -c -o Release/obj.target/gt2d/myobject.o ../myobject.cc
flock ./Release/linker.lock g++ -shared -pthread -rdynamic -m64 -Wl,-soname=gt2d.node -o Release/obj.target/gt2d.node -Wl,--start-group Release/obj.target/gt2d/gt2d.o Release/obj.target/gt2d/myobject.o -Wl,--end-group -lgt2d -lv8 /usr/lib/libgt2d.so.1
SOLINK_MODULE(target) Release/obj.target/gt2d.node: Finished
rm -rf "Release/gt2d.node" && cp -af "Release/obj.target/gt2d.node" "Release/gt2d.node"