-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't build on Windows #3
Comments
I think I found the root cause: the node module is compiled with the /MT option (the C/C++ Run Time is to be statically linked) That's not correct. On Windows with Visual Studio, all libs linked to a DLL must use the same option with respect to link to C/C++ Run Time. The module build fine after MANUALLY changing /MD to /MT in the Visual Studio projects for the two libraries. |
I don't have access to Windows at the moment. Does this change fix it for you?: diff --git a/binding.gyp b/binding.gyp
index 58e26fd..0970aa5 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -43,7 +43,7 @@
'variables': { 'cmake_arch': 'x64' },
}],
],
- 'action': [ 'cd <(module_root_dir)/deps/cpu_features/build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PIC=ON -A <(cmake_arch) ..' ],
+ 'action': [ 'cd <(module_root_dir)/deps/cpu_features/build && cmake -DCMAKE_CXX_FLAGS_RELEASE="/MT" -DCMAKE_BUILD_TYPE=Release -DBUILD_PIC=ON -A <(cmake_arch) ..' ],
}, { # POSIX
'outputs': [ '<(module_root_dir)/deps/cpu_features/build/Makefile' ],
'action': [ |
I juste cloned and patched. What command should I launch in my cmd.exe to trigger the same kind of build that npm install is doing? |
Either |
I had to do npm install nan, and after that I could do node-gyp configure and node-gyp build (or rebuild) But the problem persist, the two libraries project .\deps\cpu_features\build\cpu_features.vcxproj and .\deps\cpu_features\build\utils.vcxproj are still with switch /MD |
Fof what it's worth, I tried to run the command:
-- Build files have been written to: C:/xxxxxxx/git/cpu-features-source/deps/cpu_features/build |
Huh.... what about |
Still failing to build, for the same reasons.
|
You could take a look at https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake |
That's where the suggestions I gave came from. I'm not a Cmake expert either. |
I managed to have cmake generates valid Visual Studio projects for the two libs from deps, that is: with the Code Generation Run Time Library set to Multi threaded (/MT) by running the command: But when I try to patch the binding.gyp file with:
and then use node-gyg build I have: |
Are you using the latest version of node-gyp to rebuild? It seems that this behavior was reverted in node-gyp 8.0.0 with its inclusion of gyp 0.7.0: msvs: On Windows, arguments passed to the "action" commands are no longer transformed to replace slashes with backslashes. If you're still encountering this on node-gyp 8.0.0 or newer, you should post an issue about this on their issue tracker here because evidently that shouldn't be happening anymore. Unfortunately as of this writing, npm hasn't pulled in node-gyp 8.0.0+, so it will be awhile yet before someone can |
Also, which version of CMake are you using? |
Out of curiosity, what if you use a dash instead of a forward slash, supposedly that is supported by the msvs compiler/linker for their command line arguments as well:
|
node-gyp 8.2.0 Yes, the dash trick made it!
Please publish a new version adding |
Why didn't you bump the version and update on npmjs.com? |
Windows 10 Enterprise 64 bits 21H1 build 19043.1237
node v14.17.6
npm 6.14.15
cmake 3.21.3
Visual Studio Enterprise 2019 Version 16.11.3
MSVCRT.lib(chandler4gs.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function
__except_handler4 [c:\xxxxxxx\git\sdk\v2\master\node_modules\yyyy\node_modules\cpu-features\build\cpufeatures.
vcxproj]
c:\xxxxxxx\git\sdk\v2\master\node_modules\yyyy\node_modules\cpu-features\build\Release\cpufeatures.node : fatal
error LNK1120: 1 unresolved externals [c:\xxxxxxx\git\sdk\v2\master\node_modules\irpa_core\node_modules\cpu-feature
s\build\cpufeatures.vcxproj]
The text was updated successfully, but these errors were encountered: