How to link .dll into a windows build?
See original GitHub issue- Node Version: v8.11.3
- NPM version: 6.9.0
- node-gyp version: 3.8.0
- Platform: Windows 10, 64 bit
Hey there, hoping someone can help me. I’ve been battling with this for the last two days.
I’m currently wrapping a library written in c. It is quite a big library with many of it’s own header includes, although relies on only one .lib file. I’m struggling to understand exactly how to link a custom .lib file into my build. It seems simple enough but it’s not working as expected.
After playing around quite a bit, I’ve managed to get my project to build using the binding.gyp file shown below. Then when I try use require('SAF_native')
in my .js file, it throws the all too familiar module could not be found.
error.
Now interestingly, when I go into the VS .sln, I can find my build settings seem to be correct. I see that for the project build settings:
- the C/C++ tab option ‘Additional Include Directories’ has my ‘include_dirs’ paths from the .gyp file.
- the Linker tab option ‘Additional Dependencies’ has my ‘libraries’ .lib file from the gyp file.
- I also see all the .c source files are listed correctly in the project solution.
So it seems as if everything should be working, but the .node addon just doesn’t work when I try include it in my project.
module.js:681
return process.dlopen(module, path._makeLong(filename));
^
Error: The specified module could not be found.
\\?\D:\git-repos\SAF-nodeaddon\build\Debug\SAF_native.node
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:\git-repos\SAF-nodeaddon\index.js:2:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
my binding.gyp looks like the one shown below.
{
"targets": [{
"target_name": "SAF_native",
'link_settings': {
"libraries" : [
'D:\git-repos\SAF-nodeaddon\src\Spatial_Audio_Framework\dependencies\Win64\lib\saf_mkl_custom.lib',
]
},
"include_dirs" : [
'src/Spatial_Audio_Framework/dependencies/Win64/include',
'src/Spatial_Audio_Framework/framework/include',
'src/saf_ambiDecoder.h',
"<!(node -e \"require('napi-macros')\")"
],
"sources": [
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_calloc.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_complex.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_filters.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_free.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_loudspeaker_presets.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_malloc.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_sensorarray_presets.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_sort.c",
"src/Spatial_Audio_Framework/framework/saf_utilities/saf_veclib.c",
"src/Spatial_Audio_Framework/framework/saf_hoa/saf_hoa_internal.c",
"src/Spatial_Audio_Framework/framework/saf_hoa/saf_hoa.c",
"src/Spatial_Audio_Framework/framework/saf_vbap/saf_vbap_internal.c",
"src/Spatial_Audio_Framework/framework/saf_vbap/saf_vbap.c",
"src/Spatial_Audio_Framework/framework/saf_sh/saf_sh_internal.c",
"src/Spatial_Audio_Framework/framework/saf_sh/saf_sh.c",
"src/main.c"
]
}]
}
Any help would be GREATLY appreciated 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
You can try asking for help in https://github.com/nodejs/help
Thank you!
I have moved this to the help issues. #1834