无法使用 Electron 构建节点 ibm_db 包
Trouble building node ibm_db package with Electron
我正在尝试构建 ibm_db 以用于 Electron 应用程序。
构建环境是windows7、64位,使用MSVS 2015。
Base Node 版本为 4.2.6,Electron 版本为 0.35.4(ibm_db 不适用于 windows 7 上的 Node 5.x,这是最新的 elctron版本使用 4.x).
我已经为 ibm 数据服务器客户端 v 10.5 安装了 CLI 驱动程序
使用 node-gyp 构建时出现以下错误输出:
C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db>node-gyp rebuild --target=0.35.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --msvs_version=2015
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@4.2.6 | win32 | x64
gyp info spawn C:\Users\my-user\AppData\Local\Continuum\Anaconda\python.EXE
gyp info spawn args [ 'C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2015',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\.node-gyp\0.35.4\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\my-user\.node-gyp\0.35.4',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
odbc.cpp
odbc_connection.cpp
..\src\odbc.cpp(835): warning C4244: 'argument': conversion from 'SQLINTEGER' to 'SQLSMALLINT', possible loss of data [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
odbc_statement.cpp
..\src\odbc_connection.cpp(115): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_connection.cpp(115): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_connection.cpp(116): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_connection.cpp(116): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
odbc_result.cpp
..\src\odbc_statement.cpp(122): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(122): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_statement.cpp(123): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(123): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_statement.cpp(124): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHSTMT' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(124): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
dynodbc.cpp
..\src\odbc_result.cpp(101): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(101): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_result.cpp(102): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(102): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_result.cpp(103): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHSTMT' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(103): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=0.35.4" "--arch=x64" "--dist-url=https://atom.io/download/atom-shell" "" "--msvs_version=2015"
gyp ERR! cwd C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db>
有什么想法吗?
--编辑--
附加信息 -
我发现,如果我窃取 OSX clidriver 文件,并使用这些文件进行构建,我不会收到构建错误。
该模块实际上并没有运行,它在尝试与已知的有效连接字符串连接时成功建立连接之前失败并显示“[Microsoft][ODBC 驱动程序管理器] 函数序列错误”。
我想这是意料之中的事。
然后我继续使用我的 IBM\SQLLIB 目录中的文件替换所有包含文件,一次一个,并不断重建直到我可以重现构建错误。
它一直保持完全相同的行为,直到我终于开始替换 "sqlsystem.h",这导致构建错误再次出现。
我尝试比较两个 sqlsystem.h 文件以查看是否有任何有意义的东西,但是,唉,我的 C++ 知识基本上是零,所以,我无法解释这些.
我终于明白了!
这个包在 win32 上构建起来非常困难 -
见下文issue.
我是这样解决的:
注意:在后续说明中,为获得最佳结果,请始终对列出的任何目录使用完全限定路径。
- 导航至:
$projectDir/node_modules/ibm_db
- 运行:
node-gyp clean
- 将
IBM_DB_HOME
环境变量设置为 $projectDir/node_modules/ibm_db/installer/clidriver
- 运行:
node-gyp configure --target=0.35.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --msvs_version=2015 --IS_DOWNLOADED=true
- 这将在您的
~./ibm_db/Build/
目录中创建一个 .vcxproj xml 文件。您将需要手动编辑此文件以删除对 'odbc32.lib' 的任何引用
- 您现在需要下载 linux(是的,真的)64 位 DB2 驱动程序的头文件 link
- tar.gz 文件中有一个
clidriver/include/
目录。复制整个 'include' 文件夹,并将其粘贴到 $projectDir/installer/clidriver/
(因此您现在拥有文件夹 $projectDir/installer/clidriver/include
)
- 现在,从您的
$projectDir/node_modules/ibm_db
目录,运行:msbuild build/binding.sln /nologo /p:Configuration=Release;Platform=x64
注意: 无论出于何种原因,msbuild 在我的机器上没有正确别名,所以我实际上必须 运行 的命令是:
"C:\Program Files (x86)\MSBuild.0\Bin\MSBuild.exe" build/binding.sln /nologo /p:Configuration=Release;Platform=x64
- 您的里程可能会有所不同。
- 哒哒!假设您没有遇到任何严重的构建错误,那么您现在终于完成了用于 Electron 的 ibm_db 包的构建。
我正在尝试构建 ibm_db 以用于 Electron 应用程序。
构建环境是windows7、64位,使用MSVS 2015。
Base Node 版本为 4.2.6,Electron 版本为 0.35.4(ibm_db 不适用于 windows 7 上的 Node 5.x,这是最新的 elctron版本使用 4.x).
我已经为 ibm 数据服务器客户端 v 10.5 安装了 CLI 驱动程序
使用 node-gyp 构建时出现以下错误输出:
C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db>node-gyp rebuild --target=0.35.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --msvs_version=2015
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@4.2.6 | win32 | x64
gyp info spawn C:\Users\my-user\AppData\Local\Continuum\Anaconda\python.EXE
gyp info spawn args [ 'C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=2015',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\my-user\.node-gyp\0.35.4\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\my-user\.node-gyp\0.35.4',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
odbc.cpp
odbc_connection.cpp
..\src\odbc.cpp(835): warning C4244: 'argument': conversion from 'SQLINTEGER' to 'SQLSMALLINT', possible loss of data [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
odbc_statement.cpp
..\src\odbc_connection.cpp(115): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_connection.cpp(115): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_connection.cpp(116): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_connection.cpp(116): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
odbc_result.cpp
..\src\odbc_statement.cpp(122): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(122): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_statement.cpp(123): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(123): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_statement.cpp(124): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHSTMT' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_statement.cpp(124): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
dynodbc.cpp
..\src\odbc_result.cpp(101): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHENV' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(101): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_result.cpp(102): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHDBC' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(102): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\src\odbc_result.cpp(103): error C2440: 'static_cast': cannot convert from 'intptr_t' to 'SQLHSTMT' [C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db\build\odbc_bindings.vcxproj]
..\src\odbc_result.cpp(103): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\my-user\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=0.35.4" "--arch=x64" "--dist-url=https://atom.io/download/atom-shell" "" "--msvs_version=2015"
gyp ERR! cwd C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
C:\Users\my-user\Node\sql_gui_test\node_modules\ibm_db>
有什么想法吗?
--编辑--
附加信息 -
我发现,如果我窃取 OSX clidriver 文件,并使用这些文件进行构建,我不会收到构建错误。
该模块实际上并没有运行,它在尝试与已知的有效连接字符串连接时成功建立连接之前失败并显示“[Microsoft][ODBC 驱动程序管理器] 函数序列错误”。
我想这是意料之中的事。
然后我继续使用我的 IBM\SQLLIB 目录中的文件替换所有包含文件,一次一个,并不断重建直到我可以重现构建错误。
它一直保持完全相同的行为,直到我终于开始替换 "sqlsystem.h",这导致构建错误再次出现。
我尝试比较两个 sqlsystem.h 文件以查看是否有任何有意义的东西,但是,唉,我的 C++ 知识基本上是零,所以,我无法解释这些.
我终于明白了!
这个包在 win32 上构建起来非常困难 -
见下文issue.
我是这样解决的:
注意:在后续说明中,为获得最佳结果,请始终对列出的任何目录使用完全限定路径。
- 导航至:
$projectDir/node_modules/ibm_db
- 运行:
node-gyp clean
- 将
IBM_DB_HOME
环境变量设置为$projectDir/node_modules/ibm_db/installer/clidriver
- 运行:
node-gyp configure --target=0.35.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --msvs_version=2015 --IS_DOWNLOADED=true
- 这将在您的
~./ibm_db/Build/
目录中创建一个 .vcxproj xml 文件。您将需要手动编辑此文件以删除对 'odbc32.lib' 的任何引用
- 您现在需要下载 linux(是的,真的)64 位 DB2 驱动程序的头文件 link
- tar.gz 文件中有一个
clidriver/include/
目录。复制整个 'include' 文件夹,并将其粘贴到$projectDir/installer/clidriver/
(因此您现在拥有文件夹$projectDir/installer/clidriver/include
) - 现在,从您的
$projectDir/node_modules/ibm_db
目录,运行:msbuild build/binding.sln /nologo /p:Configuration=Release;Platform=x64
注意: 无论出于何种原因,msbuild 在我的机器上没有正确别名,所以我实际上必须 运行 的命令是:
"C:\Program Files (x86)\MSBuild.0\Bin\MSBuild.exe" build/binding.sln /nologo /p:Configuration=Release;Platform=x64
- 您的里程可能会有所不同。
- 哒哒!假设您没有遇到任何严重的构建错误,那么您现在终于完成了用于 Electron 的 ibm_db 包的构建。