[英]'IM003', '[IM003] system error 126: The specified module could not be found (When using ICU library)
在我的職業生涯中第一次在windows
中構建 C/C++ 代碼,
我需要更改“遺留”( odbc )代碼以使用新的( ICU ,靜態)庫。
我通過 Vidual studio (2015) 更改了代碼,並通過項目屬性添加了 include 和 lib 依賴項。
構建 (dll) 和打包 (msi) 是通過命令行中的腳本完成的。
如果我構建原始代碼庫而不做任何更改,應用程序將按預期工作。
當我添加最少的 ICU 相關內容時,我收到一個錯誤:
#include <unicode/ucnv.h>
#include <unicode/unistr.h>
#include <unicode/urename.h>
#include <unicode/stringpiece.h>
// Unicode version of SQLExecDirect.
//
SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT phstmt,
SQLWCHAR* pwCmd,
SQLINTEGER cchLen)
{
icu::UnicodeString ustr(pwCmd, cchLen*sizeof(SQLWCHAR));
//...
}
當我使用以下方法測試構建時:
import pyodbc
query = 'anything'
statement = f"SELECT '{query}'"
print(statement)
cnxn = pyodbc.connect('Driver={Amazon Redshift ODBC Driver (x64)};Server=xxx;Port=5439;Database=dev;UID=xxx;PWD=xxx')
cursor = cnxn.cursor()
cursor.execute(statement)
val = cursor.fetchall()[0][0]
我得到:
InterfaceError Traceback (most recent call last)
xxx\Documents\test.py in line 9
10 query = 'anything'
11 statement = f"SELECT '{query}'"
----> 12 cnxn = pyodbc.connect('Driver={Amazon Redshift ODBC Driver (x64)};Server=xxx;Port=5439;Database=dev;UID=xxx;PWD=xxx')
13 cursor = cnxn.cursor()
InterfaceError: ('IM003', '[IM003] Specified driver could not be loaded due to system error 126:
The specified module could not be found.
(Amazon Redshift ODBC Driver (x64), C:\\Program Files\\Amazon Redshift ODBC Driver x64\\Drivers\\rsodbc.dll).
(160) (SQLDriverConnect)')
dumpbin
,它似乎不包含 SQLDriverConnect 在鏈接 ICU lib 之前出現的方式(雖然不是 100% 確定)有什么提示嗎?
使用Dependencies
應用檢查我的 odbc.dll,我意識到,我還需要將 icuuc70.dll 和 icudt70.dll 包含在與我的 odbc.dll.8 相同的文件夾中 (我剛剛鏈接到 icu*.lib 文件)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.