question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bzozcommented, Mar 21, 2019

You can try asking for help in https://github.com/nodejs/help

0reactions
tonetechniciancommented, Mar 21, 2019

Thank you!

I have moved this to the help issues. #1834

Read more comments on GitHub >

github_iconTop Results From Across the Web

Link an executable to a DLL
An import library to link into your executable. The linker creates the import library when the DLL is built. For more information, see...
Read more >
How to build and use DLLs on Windows
Back to cl , just add square.lib as another input. You don't actually need square.dll present at link time. ... What if you...
Read more >
Linking dll in Visual Studio - c++
On Windows you do not link with a .dll file directly – you must use the accompanying .lib file instead. To do that...
Read more >
How-To Create And Use A DLL (Dynamic Link ... - YouTube
In this video, we walk through how to create a dynamic link library ( DLL ) and then put it to use right...
Read more >
Building and Using DLLs
DLLs are Dynamic Link Libraries, which means that they're linked into your program at run time instead of build time. There are three...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found