ayoubserti / node-iohook

Binding of libuiohook for nodejs
22 stars 11 forks source link

VS2015 > Compilation error (Macro definition of snprintf conflicts with Standard Librar y function declaration). Any idea how to fix it? #8

Closed soyFerrero closed 7 years ago

soyFerrero commented 7 years ago

`cmake-js compile

info TOOL Using Visual Studio 14 2015 Win64 generator. info CMD BUILD info RUN cmake --build "E:\node-iohook\build" --config Release Microsoft (R) Build Engine version 14.0.25420.1 Copyright (C) Microsoft Corporation. All rights reserved.

Build started 5/26/2017 6:46:13 PM. Project "E:\node-iohook\build\ALL_BUILD.vcxproj" on node 1 (default targets). Project "E:\node-iohook\build\ALL_BUILD.vcxproj" (1) is building "E:\node-iohook\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets). InitializeBuildStatus: Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. CustomBuild: All outputs are up-to-date. FinalizeBuildStatus: Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate". Done Building Project "E:\node-iohook\build\ZERO_CHECK.vcxproj" (default targets).

Project "E:\node-iohook\build\ALL_BUILD.vcxproj" (1) is building "E:\node-iohook\build\libuiohook\demo_hook.vcxproj" (3) on node 1 (default targets). Project "E:\node-iohook\build\libuiohook\demo_hook.vcxproj" (3) is building "E:\node-iohook\build\libuiohook\uiohook.vcxproj" (4) on node 1 (default targets). InitializeBuildStatus: Touching "uiohook.dir\Release\uiohook.tlog\unsuccessfulbuild". CustomBuild: All outputs are up-to-date. ClCompile: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /I"E:\node-iohook\build\libuiohook\include" /I"E:\node-iohook\libuiohook\include" /I"E :\node-iohook\libuiohook\src" /nologo /W3 /WX- /O2 /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D inline=__inline /D _CRT_SECURE_NO_WARNINGS /D snprintf=snprintf /D "CMAKE INTDIR=\"Release\"" /D uiohook_EXPORTS /D _WINDLL /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"uiohook.dir\Release\" /Fd"uiohook.dir\Re lease\vc140.pdb" /Gd /TC /errorReport:queue "E:\node-iohook\libuiohook\src\logger.c" "E:\node-iohook\libuiohook\src\windows\input_helper.c" "E:\node-iohook\libuiohoo k\src\windows\post_event.c" logger.c C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohook. vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): note: command-line arguments: see previous definition of 'snprintf' C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Librar y function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj] input_helper.c C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohook. vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): note: command-line arguments: see previous definition of 'snprintf' C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Librar y function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj] post_event.c C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohook. vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): note: command-line arguments: see previous definition of 'snprintf' C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Librar y function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj] Generating Code... Done Building Project "E:\node-iohook\build\libuiohook\uiohook.vcxproj" (default targets) -- FAILED.

Done Building Project "E:\node-iohook\build\libuiohook\demo_hook.vcxproj" (default targets) -- FAILED.

Done Building Project "E:\node-iohook\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.

Build FAILED.

"E:\node-iohook\build\ALL_BUILD.vcxproj" (default target) (1) -> "E:\node-iohook\build\libuiohook\demo_hook.vcxproj" (default target) (3) -> "E:\node-iohook\build\libuiohook\uiohook.vcxproj" (default target) (4) -> (ClCompile target) -> C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohoo k.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohoo k.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1931): warning C4005: 'snprintf': macro redefinition [E:\node-iohook\build\libuiohook\uiohoo k.vcxproj]

"E:\node-iohook\build\ALL_BUILD.vcxproj" (default target) (1) -> "E:\node-iohook\build\libuiohook\demo_hook.vcxproj" (default target) (3) -> "E:\node-iohook\build\libuiohook\uiohook.vcxproj" (default target) (4) -> (ClCompile target) -> C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Libr ary function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Libr ary function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1933): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Libr ary function declaration [E:\node-iohook\build\libuiohook\uiohook.vcxproj]

3 Warning(s)
3 Error(s)`
ayoubserti commented 7 years ago

Hi @soyFerrero Normally, the module compile fine using VS2015 Win64. In case you are building from source you can workaround by making a small hack in libuiohook/CMakeList

https://github.com/ayoubserti/libuiohook/blob/cd94ddb439fcd0740d93a0e38f7e5ece8213783f/CMakeLists.txt#L76

and https://github.com/ayoubserti/libuiohook/blob/cd94ddb439fcd0740d93a0e38f7e5ece8213783f/CMakeLists.txt#L89

Remove -Dsnprintf=_snprintf

-Ayb

soyFerrero commented 7 years ago

Now works. Thank you. Another problem appeared when I execute ( npm run test) This happened before with another librarie (iohook). Any idea what it could be?

`E:\node-iohook\node_modules\bindings\bindings.js:83 throw e ^

Error: The specified module could not be found. \?\E:\node-iohook\build\Release\node-iohook.node at Error (native) at Object.Module._extensions..node (module.js:568:18) at Module.load (module.js:456:32) at tryModuleLoad (module.js:415:12) at Function.Module._load (module.js:407:3) at Module.require (module.js:466:17) at require (internal/module.js:20:19) at bindings (E:\node-iohook\node_modules\bindings\bindings.js:76:44) at Object. (E:\node-iohook\test.js:1:104) at Module._compile (module.js:541:32) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-iohook@0.0.1 test: node test.js npm ERR! Exit status 1`

soyFerrero commented 7 years ago

Complete log

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'test' ] 2 info using npm@5.0.0 3 info using node@v6.0.0 4 verbose run-script [ 'pretest', 'test', 'posttest' ] 5 info lifecycle node-iohook@0.0.1~pretest: node-iohook@0.0.1 6 silly lifecycle node-iohook@0.0.1~pretest: no script for pretest, continuing 7 info lifecycle node-iohook@0.0.1~test: node-iohook@0.0.1 8 verbose lifecycle node-iohook@0.0.1~test: unsafe-perm in lifecycle true 9 verbose lifecycle node-iohook@0.0.1~test: PATH: C:\Users\ferrero\AppData\Roaming\nvm\v6.0.0\node_modules\npm\bin\node-gyp-bin;E:\node-iohook\node_modules.bin;C:\Cmder\bin;C:\Cmder\vendor\conemu-maximus5\ConEmu\Scripts;C:\Cmder\vendor\conemu-maximus5;C:\Cmder\vendor\conemu-maximus5\ConEmu;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\ferrero\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\GNU\GnuPG\pub;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin;C:\Cmder\vendor\git-for-windows\bin;C:\Program Files (x86)\Graphviz2.38\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft Visual C++ Build Tools;C:\Python27;%MINGW_DIR%\bin;C:\MinGW\bin;C:\WINDOWS\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Windows\System32;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC;C:\Program Files\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;C:\Users\ferrero\AppData\Local\Microsoft\WindowsApps;C:\Users\ferrero\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Users\ferrero\AppData\Roaming\npm;C:\Users\ferrero\AppData\Local\Yarn.bin;;C:\Cmder\vendor\git-for-windows\usr\bin;C:\Cmder\vendor\git-for-windows\usr\share\vim\vim74;C:\Cmder\ 10 verbose lifecycle node-iohook@0.0.1~test: CWD: E:\node-iohook 11 silly lifecycle node-iohook@0.0.1~test: Args: [ '/d /s /c', 'node test.js' ] 12 silly lifecycle node-iohook@0.0.1~test: Returned: code: 1 signal: null 13 info lifecycle node-iohook@0.0.1~test: Failed to exec test script 14 verbose stack Error: node-iohook@0.0.1 test: node test.js 14 verbose stack Exit status 1 14 verbose stack at EventEmitter. (C:\Users\ferrero\AppData\Roaming\nvm\v6.0.0\node_modules\npm\lib\utils\lifecycle.js:283:16) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at EventEmitter.emit (events.js:191:7) 14 verbose stack at ChildProcess. (C:\Users\ferrero\AppData\Roaming\nvm\v6.0.0\node_modules\npm\lib\utils\spawn.js:40:14) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at ChildProcess.emit (events.js:191:7) 14 verbose stack at maybeClose (internal/child_process.js:850:16) 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5) 15 verbose pkgid node-iohook@0.0.1 16 verbose cwd E:\node-iohook 17 verbose Windows_NT 10.0.16193 18 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "test" 19 verbose node v6.0.0 20 verbose npm v5.0.0 21 error code ELIFECYCLE 22 error errno 1 23 error node-iohook@0.0.1 test: node test.js 23 error Exit status 1 24 error Failed at the node-iohook@0.0.1 test script. 24 error This is probably not a problem with npm. There is likely additional logging output above. 25 verbose exit [ 1, true ]

soyFerrero commented 7 years ago

it fixed up!!. Thanks for your time