Мне нужно скомпилировать модуль Managed C ++ в приложении Node.JS. Я читал в Интернете, что мне нужно включить CLI с флагом / clr и установить атрибуты msvs-settings и msbuild_settings, у меня все еще не работает. Я получаю это сообщение об ошибке:
cl: ошибка командной строки D8016: параметры командной строки '/ clr' и '/ EHs' несовместимы [C: \ MyProject \ native-modules \ encryption -utilities \ addon \ build \ encrypt.vcxproj]
Я получил информацию с этой страницы: https://github.com/nodejs/node-gyp/issues/568
Вот моя привязка. gyp.
Спасибо.
{
"targets": [
{
"target_name": "encrypt",
'conditions': [
['OS=="mac"', {
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"GCC_ENABLE_CPP_RTTI": "YES",
"OTHER_CFLAGS": ["-mmacosx-version-min=10.7", "-std=c++11", "-stdlib=libc++"],
"OTHER_CPLUSPLUSFLAGS": ["-mmacosx-version-min=10.7", "-std=c++11", "-stdlib=libc++"]
},
'defines': [
'LINUX_DEFINE',
'_MAC',
'_ULONGLONG',
],
"cflags": ["-Wall", "-std=c++11", '-fexceptions', '-Wno-writable-strings'],
"cflags!": ['-fno-exceptions', '-Wwritable-strings'],
"cflags_cc!": ['-fno-exceptions', '-Wwritable-strings'],
"cflags_cc": ['-fexceptions', '-Wno-writable-strings'],
"include_dirs": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
]
}],
['OS=="win"', {
'defines+': [
'WIN_DEFINE',
'INCLUDE_SIGNATURE_ENCRYPTION',
'WIN64',
'WIN32',
'_WIN32',
"_WIN32_WINNT=0x0601",
"_WINSOCK_DEPRECATED_NO_WARNINGS",
"_HAS_EXCEPTIONS=2",
"_SCL_SECURE_NO_WARNINGS",
"UNICODE",
"_UNICODE",
"_NO_ASYNCRTIMP",
"BOOST_ERROR_CODE_HEADER_ONLY"
],
'msbuild_toolset': 'v141',
{
'cflags_cc': [
'/clr'
],
}],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary':'MultiThreadedDLL'
}
},
'msbuild_settings': {
'ClCompile': {
'CompileAsManaged':'true' # can be safe, pure
}
},
"include_dirs": [
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
],
# "run_as": {
# "action": ['C:/Program Files/nodejs/node.exe', '$(ProjectDir)/../../out/encrypt.js', ],
# },
"configurations": {
"Debug": {
'defines': [
'DEBUG',
'_DEBUG'
],
'library_dirs': [
],
},
"Release": {
'defines': [
'NDEBUG',
],
'library_dirs': [
],
}
},
"libraries": [
"crypt32.lib",
"winhttp.lib",
"httpapi.lib",
"bcrypt.lib",
"ws2_32.lib",
"iphlpapi.lib"
]
}]
],
"sources": [
"hello.cc",
"aes.cpp",
"base64.cpp",
"crypt.cpp",
"StringUtil.cpp"
],
"cflags": ["-Wall", "-std=c++11"],
"cflags!": ['-fno-exceptions'],
"cflags_cc!": ['-fno-exceptions'],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"addon",
"addon/include",
"../addon/include",
"C:/Projects/C++/vcpkg/installed/x64-windows/include",
"include",
".."
]
},
{
"target_name": "copy_binary",
"type": "none",
"dependencies": ["encrypt"],
'conditions': [
[
'OS=="mac"', {
"copies": [
{
"destination": "<(module_root_dir)/mac/",
"files": ["<(module_root_dir)/build/Release/encrypt.node"]
}
],
}
],
[
'OS=="win"', {
'msbuild_toolset': 'v141',
{
'cflags_cc': [
'/clr'
],
}],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary':'MultiThreadedDLL'
}
},
'msbuild_settings': {
'ClCompile': {
'CompileAsManaged':'true' # can be safe, pure
}
},
"configurations": {
"Debug": {
"copies": [
{
"destination": "<(module_root_dir)/win32/",
"files": ["<(module_root_dir)/build/Debug/encrypt.node", "<(module_root_dir)/build/Debug/encrypt.pdb"]
}
]
},
"Release": {
"copies": [
{
"destination": "<(module_root_dir)/win32/",
"files": ["<(module_root_dir)/build/Release/encrypt.node", "<(module_root_dir)/build/Release/encrypt.pdb"]
}
]
},
}
}
],
]
}
]
}