Cannot get node -gyp to create windows solution using / MD

I want to compile the node.js module with the / MD flag (multi-threaded DLL). The presence of / MD in the cflags options in bind.gyp does not work.

+4
source share
3 answers

You need to set RuntimeLibrary to 2 . Something like that:

 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 2, # multi threaded DLL }, }, 
+3
source

After playing with binding.gyp - a lot - it seems that the problem is not that the problem is with node -gyp, but with regard to the gyp itself and the most specific nesting order, which is required for certain settings. That is, to install the runtime library (in the version), the runtime library option must be attached to the gyp file as follows:

 configurations - Release - msvs_settings - VCCLCompilerTool - RuntimeLibrary 

Attempting to install a runtime library without any of these nesting elements will stop the installation of the runtime library. (Annoying, without any warning that this parameter is ignored.)

Therefore, to install the debug and release modules for using the runtime debugging DLL (compiler option / MDd) and the runtime DLLs released (compiler option / MDd), binding.gyp will look like this:

 { 'targets': [ { # Usual target name/sources, etc. 'configurations': { 'Debug': { 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': '3' # /MDd }, }, }, 'Release': { 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': '2' # /MD }, }, }, }, },], } 
+2
source

For my project, the only solution was to create a new configuration and inherit the original configuration:

  'target_defaults': { 'configurations': { 'ChirpDebug' : { 'inherit_from': ['Debug'], 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': '3' }, }, }, 'ChirpRelease' : { 'inherit_from': ['Release'], 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': '2' }, }, }, }, 

and then use

 msbuild /p:Configuration=ChirpDebug .... 

I tried this solution with libuv and it works well. I don't know about node -gyp, but a similar approach should work.

0
source

Source: https://habr.com/ru/post/1447171/


All Articles