静态编译时如何摆脱OCI.dll依赖
我的应用程序通过 Qt 的 QSqlDatabase 类访问 Oracle 数据库。
我正在将 Qt 编译为静态版本以用于发布版本,但我似乎无法摆脱 OCI.dll 依赖性。我正在尝试链接 oci.lib(在带有 SDK 的 Oracle 即时客户端中可用)。
这是我的 configure 行:
configure -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -static -release -opensource -plugin-sql-oci -plugin-sql-sqlite -platform win32-msvc2005
我通过以下方式链接到 SDK 文件夹中的 oci.h 和 oci.lib:
set INCLUDE=C:\oracle\instantclient\sdk\include;%INCLUDE%
set LIB=C:\oracle\instantclient\sdk\lib\msvc;%LIB%
然后,编译 Qt 后,我在 *.pro 文件中使用以下行:
QT += sql
CONFIG += static
LIBS += C:\oracle\instantclient\sdk\lib\msvc\oci.lib
QTPLUGIN += qsqloci
然后,在我的 main.cpp 中,我添加以下命令来静态编译应用程序中的 OCI 插件:
#include <QtPlugin>
Q_IMPORT_PLUGIN(qsqloci)
编译项目后,我在我的工作站上测试它并且它可以工作(因为我安装了 Oracle Instant Client) 。当我尝试在另一个工作站上时,我总是收到以下消息:
该应用程序无法启动 因为没有找到OCI.dll。 重新安装此应用程序可能会修复 这个问题。
我不明白为什么我仍然需要 OCI.dll,因为我的静态链接应用程序应该链接到 oci.lib。
这里有 Qt 人员可以为我提供解决方案吗?
多谢 !
STL
My application accesses an Oracle database through Qt's QSqlDatabase class.
I'm compiling Qt as static for the release build, but I can't seem to be able to get rid of OCI.dll dependency. I'm trying to link against oci.lib (as available in Oracle's Instant Client with SDK).
Here's my configure line :
configure -qt-libjpeg -qt-zlib -qt-libpng -nomake examples -nomake demos -no-exceptions -no-stl -no-rtti -no-qt3support -no-scripttools -no-openssl -no-opengl -no-phonon -no-style-motif -no-style-cde -no-style-cleanlooks -no-style-plastique -static -release -opensource -plugin-sql-oci -plugin-sql-sqlite -platform win32-msvc2005
I link against oci.h and oci.lib in the SDK's folder by using :
set INCLUDE=C:\oracle\instantclient\sdk\include;%INCLUDE%
set LIB=C:\oracle\instantclient\sdk\lib\msvc;%LIB%
Then, once Qt is compiled, I use the following lines in my *.pro file :
QT += sql
CONFIG += static
LIBS += C:\oracle\instantclient\sdk\lib\msvc\oci.lib
QTPLUGIN += qsqloci
Then, in my main.cpp, I add the following commands to statically compile OCI plugin in the application :
#include <QtPlugin>
Q_IMPORT_PLUGIN(qsqloci)
After compiling the project, I test it on my workstation and it works (as I have Oracle Instant Client installed). When I try on another workstation, I always get the message:
This application has failed to start
because OCI.dll was not found.
Re-installing this application may fix
this problem.
I don't understand why I still need OCI.dll, as my statically linked application is supposed to link to oci.lib instead.
Is there any Qt people here that might have a solution for me ?
Thanks a lot !
STL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您链接的 .lib 文件不是您想象的那样。它是 DLL 的导入库,链接器需要它,以便知道 oci.dll 实现了哪些功能。我没有看到 Oracle 提供该库的静态版本,但没有仔细查找。这对于数据库接口来说是非常典型的。
您需要遵循 oci.dll 的部署说明,即 本文档。改变路径,哦高兴。
The .lib file you linked is not what you think it is. It is the import library for the DLL, the linker needs it so it knows what functions are implemented by oci.dll. I don't see a static version of the library available from Oracle but didn't look too hard. That's pretty typical for dbase interfaces.
You'll need to follow the deployment instructions for oci.dll, "OCI Instant Client Installation Process" in this document. Changing the PATH, oh joy.