【问题标题】:Trouble building node ibm_db package with Electron使用 Electron 构建节点 ibm_db 包时遇到问题
【发布时间】:2016-03-16 05:01:05
【问题描述】:

我正在尝试构建用于电子应用程序的 ibm_db。

构建环境是windows 7,64位,使用MSVS 2015。

Base Node 版本是 4.2.6,Electron 版本是 0.35.4(ibm_db 不适用于 Windows 7 上的 Node 5.x,这是使用 4.x 的最新 elctron 版本)。

我已经为 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\14.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\14.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 Driver Manager] Function sequence error”。

我猜这是意料之中的。

然后,我开始使用我的 IBM\SQLLIB 目录中的文件替换所有包含文件,一次一个,并不断重建,直到我可以重现生成错误。

它一直保持完全相同的行为,直到我终于开始替换“sqlsystem.h”,这导致再次出现构建错误。

我尝试比较两个 sqlsystem.h 文件以查看是否有任何意义,但是,唉,我的 C++ 知识基本上为零,所以我无法解释这些。

【问题讨论】:

  • 如果您使用--msvs_version=2015 为常规 Node v4 x64 构建它是否有效?
  • npm install 会在 vanilla Node 4.2.6 上进行功能安装,重建会产生相同的错误。如果我在安装期间将包指向 IBM_db 下载的文件,而不是为 ibm 数据服务器客户端下载的驱动程序文件,则会收到有关缺少 sqlcli1.h 文件的错误,该文件确实不存在。在为 vanilla Node 构建和为 electron 构建之间,这种行为再次相同。我怀疑我缺少一个 gyp 构建标志,或者我安装了错误的驱动程序,但我对如何进一步调查有点茫然。

标签: node.js db2 electron


【解决方案1】:

我终于明白了!

这个包很难在 win32 上构建 -

请参阅以下issue

我是这样解决的:

注意:在后续说明中,为获得最佳效果,请始终使用列出的任何目录的完全限定路径。

  1. 导航到:$projectDir/node_modules/ibm_db
  2. 运行:node-gyp clean
  3. IBM_DB_HOME环境变量设置为$projectDir/node_modules/ibm_db/installer/clidriver
  4. 运行:node-gyp configure --target=0.35.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --msvs_version=2015 --IS_DOWNLOADED=true
  5. 这将在您的~./ibm_db/Build/ 目录中创建一个.vcxproj xml 文件。您需要手动编辑此文件以删除对“odbc32.lib”的任何引用
  6. 您现在需要下载 linux(是的,真的)64 位 DB2 驱动程序的头文件link
  7. 在 tar.gz 文件中是一个 clidriver/include/ 目录。复制整个“包含”文件夹,并将其粘贴到 $projectDir/installer/clidriver/(这样您现在就有了文件夹 $projectDir/installer/clidriver/include
  8. 现在,从您的$projectDir/node_modules/ibm_db 目录运行:msbuild build/binding.sln /nologo /p:Configuration=Release;Platform=x64

注意:无论出于何种原因,msbuild 在我的机器上没有正确别名,所以我实际必须运行的命令是: "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" build/binding.sln /nologo /p:Configuration=Release;Platform=x64 - 您的里程可能会有所不同。

  1. 达达!假设您没有遇到任何严重的构建错误,那么您现在终于完成了构建用于 Electron 的 ibm_db 包。

【讨论】:

    猜你喜欢
    • 2015-01-01
    • 2020-02-18
    • 2021-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-26
    • 2020-05-27
    相关资源
    最近更新 更多