问题
I am writing nodejs code and want to use C++ code (backend.cpp which includes 'mysql/mysql.h') using node-gyp to compile. I am getting this error while building:
module.js:356 Module.extensions[extension](this, filename); ^ Error: ____/build/Release/backend.node: undefined symbol: mysql_init
Can anyone help? How can I instruct node-gyp to link mysql.h to the target backend.node?
回答1:
Have you added it in the libraries
list in your binding.gyp file?
Here's a short example:
{
"targets": [
{
"target_name": "backend",
"sources": [<comma separated source names>],
"include_dirs":[<comma separated include dirs>],
"libraries": [<comma separated library paths>]
}
]
}
You should also take a look at the complete Gyp Language Specification
来源:https://stackoverflow.com/questions/17145249/how-to-include-c-libraries-so-that-node-gyp-can-link