QT QOCI驱动编译

这段开始学习QT,发觉QT挺好玩的,QTSQL编程,因为用的是QT开源版,没有现成的Oracle驱动可用,就自己编译一个,在网上搜了下文章,都是QT4.XX的,我比较喜欢新版的,现在QT的最新版本是QT5.4,就打算编译5.4版本的,想着可以很快搞定,其实也比较麻烦,中间出了很多问题,现在写个博客记录下来,以备后用。

我的编译环境是Windows7,用了两个编译环境,一个VS2013,和MinGW4.9.1.

首先说MinGW4.9.1版的,我用的是qt-opensource-windows-x86-mingw491_opengl-5.4.0.exe,Oracle客户端用的是11GR2的win32位(win32_11gR2_client.zip),安装QT的时候全部选择,会自动安装MinGW4.9.1,打开开始目录里面QT安装目录里的命令行工具QT5.4 XX for desktop,执行命令如下:

set INCLUDE=%INCLUDE%;E:\Qt\Qt5.4.0\5.4\mingw491_32\include;D:\app\Administrator\product\11.2.0\client_1\oci\include

set LIB=%LIB%;E:\Qt\Qt5.4.0\5.4\mingw491_32\lib;D:\app\Administrator\product\11.2.0\client_1\oci\lib\msvc

cd E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci

qmake -o MakeFile oci.pro

mingw32-make


输出如下:

Setting up environment for Qt usage...

E:\Qt\Qt5.4.0\5.4\mingw491_32>set INCLUDE=%INCLUDE%;E:\Qt\Qt5.4.0\5.4\mingw491_3
2\include;D:\app\Administrator\product\11.2.0\client_1\oci\include

E:\Qt\Qt5.4.0\5.4\mingw491_32>set LIB=%LIB%;E:\Qt\Qt5.4.0\5.4\mingw491_32\lib;D:
\app\Administrator\product\11.2.0\client_1\oci\lib\msvc

E:\Qt\Qt5.4.0\5.4\mingw491_32>cd E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldri
vers\oci

E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci>qmake -o MakeFile oci.pr
o

E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci>mingw32-make
mingw32-make -f MakeFile.Release all
mingw32-make[1]: Entering directory 'E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sq
ldrivers/oci'
E:\Qt\Qt5.4.0\5.4\mingw491_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_N
O_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT
_CORE_LIB -D__GNUC__ -DWIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-g++ -I
E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/ming
w491_32/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore/5.4.
0/QtCore -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4
/mingw491_32/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include -
IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/inc
lude/QtCore main.cpp -o .moc\release\main.moc
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0
\5.4\mingw491_32\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\
QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:
\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\ming
w491_32\include" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include\QtCore" -I".moc\release" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\i
nclude" -I"..\..\..\..\mkspecs\win32-g++" -o .obj\release\main.o main.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0
\5.4\mingw491_32\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\
QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:
\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\ming
w491_32\include" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include\QtCore" -I".moc\release" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\i
nclude" -I"..\..\..\..\mkspecs\win32-g++" -o .obj\release\qsql_oci.o ..\..\..\sq
l\drivers\oci\qsql_oci.cpp
E:\Qt\Qt5.4.0\5.4\mingw491_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_N
O_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT
_CORE_LIB -D__GNUC__ -DWIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-g++ -I
E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/ming
w491_32/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore/5.4.
0/QtCore -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4
/mingw491_32/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include -
IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/inc
lude/QtCore ..\..\..\sql\drivers\oci\qsql_oci_p.h -o .moc\release\moc_qsql_oci_p
.cpp
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -W
all -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCE
PTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0
\5.4\mingw491_32\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\
QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:
\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\ming
w491_32\include" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include\QtCore" -I".moc\release" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.
0\5.4\mingw491_32\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\i
nclude" -I"..\..\..\..\mkspecs\win32-g++" -o .obj\release\moc_qsql_oci_p.o .moc\
release\moc_qsql_oci_p.cpp
windres -i qsqloci_resource.rc -o .obj\release\qsqloci_resource_res.o --include-
dir=. -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS
 -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB
g++ -Wl,-s -shared -Wl,-subsystem,windows -Wl,--out-implib,E:\Qt\Qt5.4.0\5.4\Src
\qtbase\plugins\sqldrivers\libqsqloci.a -o ..\..\..\..\plugins\sqldrivers\qsqloc
i.dll .obj/release/main.o .obj/release/qsql_oci.o .obj/release/moc_qsql_oci_p.o
 -L%LIB% -LE:\Qt\Qt5.4.0\5.4\mingw491_32\lib -LD:\app\Administrator\product\11.2
.0\client_1\oci\lib\msvc -loci -LE:/Qt/Qt5.4.0/5.4/mingw491_32/lib -lQt5Sql -lQt
5Core .obj\release\qsqloci_resource_res.o
mingw32-make[1]: Leaving directory 'E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sql
drivers/oci'
mingw32-make -f MakeFile.Debug all
mingw32-make[1]: Entering directory 'E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sq
ldrivers/oci'
E:\Qt\Qt5.4.0\5.4\mingw491_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_N
O_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D__
GNUC__ -DWIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-g++ -IE:/Qt/Qt5.4.0/
5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/mingw491_32/includ
e/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore/5.4.0/QtCore -IE:/
Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/i
nclude/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include -IE:/Qt/Qt5.4.0
/5.4/mingw491_32/include/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore ma
in.cpp -o .moc\debug\main.moc
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wa
ll -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEP
TIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0\5.4\mingw491_3
2\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtCore\5.4.0\Qt
Core" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4
\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include
" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_
32\include\QtCore" -I".moc\debug" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32
\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\include" -I"..\..\
..\..\mkspecs\win32-g++" -o .obj\debug\main.o main.cpp
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wa
ll -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEP
TIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0\5.4\mingw491_3
2\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtCore\5.4.0\Qt
Core" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4
\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include
" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_
32\include\QtCore" -I".moc\debug" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32
\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\include" -I"..\..\
..\..\mkspecs\win32-g++" -o .obj\debug\qsql_oci.o ..\..\..\sql\drivers\oci\qsql_
oci.cpp
E:\Qt\Qt5.4.0\5.4\mingw491_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_N
O_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D__
GNUC__ -DWIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-g++ -IE:/Qt/Qt5.4.0/
5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/mingw491_32/includ
e/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore/5.4.0/QtCore -IE:/
Qt/Qt5.4.0/5.4/mingw491_32/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/mingw491_32/i
nclude/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include -IE:/Qt/Qt5.4.0
/5.4/mingw491_32/include/QtSql -IE:/Qt/Qt5.4.0/5.4/mingw491_32/include/QtCore ..
\..\..\sql\drivers\oci\qsql_oci_p.h -o .moc\debug\moc_qsql_oci_p.cpp
g++ -c -pipe -fno-keep-inline-dllexport -g -std=c++0x -fno-exceptions -frtti -Wa
ll -Wextra -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEP
TIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -I"E:\Qt\Qt5.4.0\5.4\mingw491_3
2\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtCore\5.4.0\Qt
Core" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4
\mingw491_32\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include
" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\mingw491_
32\include\QtCore" -I".moc\debug" -I"%INCLUDE%" -I"E:\Qt\Qt5.4.0\5.4\mingw491_32
\include" -I"D:\app\Administrator\product\11.2.0\client_1\oci\include" -I"..\..\
..\..\mkspecs\win32-g++" -o .obj\debug\moc_qsql_oci_p.o .moc\debug\moc_qsql_oci_
p.cpp
windres -i qsqlocid_resource.rc -o .obj\debug\qsqlocid_resource_res.o --include-
dir=. -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS
 -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB
g++ -shared -Wl,-subsystem,windows -Wl,--out-implib,E:\Qt\Qt5.4.0\5.4\Src\qtbase
\plugins\sqldrivers\libqsqlocid.a -o ..\..\..\..\plugins\sqldrivers\qsqlocid.dll
 .obj/debug/main.o .obj/debug/qsql_oci.o .obj/debug/moc_qsql_oci_p.o  -L%LIB% -L
E:\Qt\Qt5.4.0\5.4\mingw491_32\lib -LD:\app\Administrator\product\11.2.0\client_1
\oci\lib\msvc -loci -LE:/Qt/Qt5.4.0/5.4/mingw491_32/lib -lQt5Sqld -lQt5Cored .ob
j\debug\qsqlocid_resource_res.o
mingw32-make[1]: Leaving directory 'E:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sql
drivers/oci'

然后就在E:\Qt\Qt5.4.0\5.4\Src\qtbase\plugins\sqldrivers目录下生成了如下文件:



再说VS版的,我机子上装的是VS2013社区版,Oracle客户端用的是11GR2的win32位(win32_11gR2_client.zip),QT编译版本是qt-opensource-windows-x86-msvc2013_opengl-5.4.0.exe,刚开始用的是qt-opensource-windows-x86-msvc2013_64_opengl-5.4.0.exe,怎么编译也不成功,后来想到我用的是Oracle32位客户端,编译64位的QT驱动是不是有问题,就换成了32位的QTqt-opensource-windows-x86-msvc2013_opengl-5.4.0.exe,结果还真好了,下面直接编译过程,分了几步,

首先是设置编译的头文件环境,可以用set设置,也可以在环境变量里面设置,我是在环境变量里面直接写的,

INCLUDE

E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include;D:\app\Administrator\product\11.2.0\client_1\oci\include;E:\Microsoft Visual Studio 12.0\VC\include

接着是LIB设置

LIB

E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\lib;D:\app\Administrator\product\11.2.0\client_1\oci\lib\msvc;E:\Microsoft Visual Studio 12.0\VC\lib
还有PATH设置

.;E:\Java\jdk1.8.0_25\bin;D:\app\Administrator\product\11.2.0\client_1\BIN;E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\bin;E:\Qt\Qt5.4.0\Tools\QtCreator\bin;E:\Microsoft Visual Studio 12.0\VC\bin;E:\Microsoft Visual Studio 12.0\Common7\IDE;E:\Microsoft Visual Studio 12.0\Common7\Tools
,这三个环境设置好了,下面就是编译,刚开始用网上的办法,几步走,

set INCLUDE=%INCLUDE%;E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl\include;D:\app\Administrator\product\11.2.0\client_1\oci\include

set LIB=%LIB%;E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl\lib;D:\app\Administrator\product\11.2.0\client_1\oci\lib\msvc

cd E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci

qmake -o MakeFile oci.pro

nmake

我就直接跳过INCLUDE和LIB设置,qmake -o MakeFile oci.pro编译正常,但是用nmake命令时,老是出错,

如下:

Setting up environment for Qt usage...
Remember to call vcvarsall.bat to complete environment setup!

E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl>nmake

Microsoft (R) 程序维护实用工具 12.00.21005.1 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

NMAKE : fatal error U1064: 未找到 MAKEFILE 并且未指定目标
Stop.

E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl>set INCLUDE=%INCLUDE%;E:\Qt\Qt5.4.0\5.4\msv
c2013_64_opengl\include;D:\app\Administrator\product\11.2.0\client_1\oci\include


E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl>set LIB=%LIB%;E:\Qt\Qt5.4.0\5.4\msvc2013_64
_opengl\lib;D:\app\Administrator\product\11.2.0\client_1\oci\lib\msvc

E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl>qmake
Usage: qmake [mode] [options] [files]

QMake has two modes, one mode for generating project files based on
some heuristics, and the other for generating makefiles. Normally you
shouldn't need to specify a mode, as makefile generation is the default
mode for qmake, but you may use this to test qmake on an existing project

Mode:
  -project       Put qmake into project file generation mode
                 In this mode qmake interprets files as files to
                 be built,
                 defaults to *; *; *; *.ts; *.xlf; *.qrc
                 Note: The created .pro file probably will
                 need to be edited. For example add the QT variable to
                 specify what modules are required.
  -makefile      Put qmake into makefile generation mode (default)
                 In this mode qmake interprets files as project files to
                 be processed, if skipped qmake will try to find a project
                 file in your current working directory

Warnings Options:
  -Wnone         Turn off all warnings; specific ones may be re-enabled by
                 later -W options
  -Wall          Turn on all warnings
  -Wparser       Turn on parser warnings
  -Wlogic        Turn on logic warnings (on by default)
  -Wdeprecated   Turn on deprecation warnings (on by default)

Options:
   * You can place any variable assignment in options and it will be     *
   * processed as if it was in [files]. These assignments will be parsed *
   * before [files].                                                     *
  -o file        Write output to file
  -d             Increase debug level
  -t templ       Overrides TEMPLATE as templ
  -tp prefix     Overrides TEMPLATE so that prefix is prefixed into the value
  -help          This help
  -v             Version information
  -after         All variable assignments after this will be
                 parsed after [files]
  -norecursive   Don't do a recursive search
  -recursive     Do a recursive search
  -set Set persistent property
  -unset   Unset persistent property
  -query   Query persistent property. Show all if is empty.
  -cache file    Use file as cache           [makefile mode only]
  -spec spec     Use spec as QMAKESPEC       [makefile mode only]
  -nocache       Don't use a cache file      [makefile mode only]
  -nodepend      Don't generate dependencies [makefile mode only]
  -nomoc         Don't generate moc targets  [makefile mode only]
  -nopwd         Don't look for files in pwd [project mode only]

E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl>cd E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins
\sqldrivers\oci

E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci>qmake -o MakeFile oci.pr
o

E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci>nmake

Microsoft (R) 程序维护实用工具 12.00.21005.1 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

        "E:\Microsoft Visual Studio 12.0\VC\bin\nmake.exe" -f MakeFile.Release a
ll

Microsoft (R) 程序维护实用工具 12.00.21005.1 版
版权所有 (C) Microsoft Corporation。  保留所有权利。

        E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_
NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_P
LUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4
.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plug
ins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtCore/5.4.0 -
IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.
0/5.4/msvc2013_64_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_ope
ngl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include -IE
:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_6
4_opengl/include/QtCore main.cpp -o .moc\release\main.moc
        E:\Qt\Qt5.4.0\5.4\msvc2013_64_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_
NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_P
LUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4
.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plug
ins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtCore/5.4.0 -
IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.
0/5.4/msvc2013_64_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_ope
ngl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include -IE
:/Qt/Qt5.4.0/5.4/msvc2013_64_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_6
4_opengl/include/QtCore ..\..\..\sql\drivers\oci\qsql_oci_p.h -o .moc\release\mo
c_qsql_oci_p.cpp
        rc -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_
NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -fo
.obj\release\qsqloci_resource.res qsqloci_resource.rc
'rc' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
NMAKE : fatal error U1077: “rc”: 返回代码“0x1”
Stop.
NMAKE : fatal error U1077: “"E:\Microsoft Visual Studio 12.0\VC\bin\nmake.exe"
”: 返回代码“0x2”
Stop.

'rc' 不是内部或外部命令,也不是可运行的程序这个问题百度了多次,没找到确切的解决办法,也不知道rc是什么东东;

后来在网上看了另一个文章,可以直接用QTcreator编译,就换成QTCreator编译,首先用QTcreator打开文件和项目,打开E:\Qt\Qt5.4.0\5.4\Src\qtbase\src\plugins\sqldrivers\oci文件夹下的oci.pro文件,这样就建了一个QT工程项目,项目设置如图:

我就自己选了个构件目录,其它都是QT自己生成,然后右键工程,先执行qmake命令,接着编译,这次就成功了,在E:\Qt\Qt5.4.0\5.4\Src\qtbase\plugins\sqldrivers目录下生成了如下几个文件

编译输出如下:


17:16:33: 为项目oci执行步骤 ...

17:16:33: 配置没有改变, 跳过 qmake 步骤。


17:16:33: 正在启动 "E:\Qt\Qt5.4.0\Tools\QtCreator\bin\jom.exe"




E:\Qt\Qt5.4.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release all


E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore main.cpp -o .moc\release\main.moc


cl -c -nologo -Zm200 -Zc:wchar_t -FS -O2 -MD -Zc:strictStrings -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\release" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\release\ @C:\Users\ADMINI~1\AppData\Local\Temp\qsql_oci.obj.59268.15.jom


qsql_oci.cpp


E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore ..\..\..\sql\drivers\oci\qsql_oci_p.h -o .moc\release\moc_qsql_oci_p.cpp


rc -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -fo .obj\release\qsqloci_resource.res qsqloci_resource.rc


Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17298




Copyright (C) Microsoft Corporation. All rights reserved.






cl -c -nologo -Zm200 -Zc:wchar_t -FS -O2 -MD -Zc:strictStrings -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\release" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\release\ @C:\Users\ADMINI~1\AppData\Local\Temp\main.obj.59268.93.jom


main.cpp


cl -c -nologo -Zm200 -Zc:wchar_t -FS -O2 -MD -Zc:strictStrings -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DNDEBUG -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\release" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\release\ @C:\Users\ADMINI~1\AppData\Local\Temp\moc_qsql_oci_p.obj.59268.125.jom


moc_qsql_oci_p.cpp


link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /SUBSYSTEM:WINDOWS /VERSION:5.40 /OUT:..\..\..\..\plugins\sqldrivers\qsqloci.dll @C:\Users\ADMINI~1\AppData\Local\Temp\qsqloci.dll.59268.1217.jom


正在创建库 ..\..\..\..\plugins\sqldrivers\qsqloci.lib 和对象 ..\..\..\..\plugins\sqldrivers\qsqloci.exp


E:\Qt\Qt5.4.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug all


E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore main.cpp -o .moc\debug\main.moc


rc -D_DEBUG -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -fo .obj\debug\qsqlocid_resource.res qsqlocid_resource.rc


Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17298




Copyright (C) Microsoft Corporation. All rights reserved.






E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\bin\moc.exe -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -D_MSC_VER=1800 -D_WIN32 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/mkspecs/win32-msvc2013 -IE:/Qt/Qt5.4.0/5.4/Src/qtbase/src/plugins/sqldrivers/oci -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore/5.4.0/QtCore -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0 -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql/5.4.0/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtSql -IE:/Qt/Qt5.4.0/5.4/msvc2013_opengl/include/QtCore ..\..\..\sql\drivers\oci\qsql_oci_p.h -o .moc\debug\moc_qsql_oci_p.cpp


cl -c -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 /Fd..\..\..\..\plugins\sqldrivers\qsqlocid.pdb -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\debug" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\debug\ @C:\Users\ADMINI~1\AppData\Local\Temp\qsql_oci.obj.38244.15.jom


qsql_oci.cpp


cl -c -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 /Fd..\..\..\..\plugins\sqldrivers\qsqlocid.pdb -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\debug" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\debug\ @C:\Users\ADMINI~1\AppData\Local\Temp\moc_qsql_oci_p.obj.38244.93.jom


moc_qsql_oci_p.cpp


cl -c -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -D_HAS_EXCEPTIONS=0 -GR -W3 -w34100 -w34189 /Fd..\..\..\..\plugins\sqldrivers\qsqlocid.pdb -DUNICODE -DWIN32 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPTIONS -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore\5.4.0\QtCore" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql\5.4.0\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtSql" -I"E:\Qt\Qt5.4.0\5.4\msvc2013_opengl\include\QtCore" -I".moc\debug" -I"..\..\..\..\mkspecs\win32-msvc2013" -Fo.obj\debug\ @C:\Users\ADMINI~1\AppData\Local\Temp\main.obj.38244.109.jom


main.cpp


link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /SUBSYSTEM:WINDOWS /VERSION:5.40 /OUT:..\..\..\..\plugins\sqldrivers\qsqlocid.dll @C:\Users\ADMINI~1\AppData\Local\Temp\qsqlocid.dll.38244.1248.jom


正在创建库 ..\..\..\..\plugins\sqldrivers\qsqlocid.lib 和对象 ..\..\..\..\plugins\sqldrivers\qsqlocid.exp


17:16:36: 进程"E:\Qt\Qt5.4.0\Tools\QtCreator\bin\jom.exe"正常退出。


17:16:36: Elapsed time: 00:04.



最后说明下,用64位的QT版本和32位的Oracle驱动编译老是出错,以下只是一部分

qsql_oci.obj:-1: error: LNK2019: 无法解析的外部符号 OCINumberToInt,该符号在函数 "public: void __cdecl QOCICols::getValues(class QVector &,int)" (?getValues@QOCICols@@QEAAXAEAV?$QVector@VQVariant@@@@H@Z) 中被引用

qsql_oci.obj:-1: error: LNK2019: 无法解析的外部符号 OCIHandleAlloc,该符号在函数 "public: __cdecl QOCIDriver::QOCIDriver(struct OCIEnv *,struct OCISvcCtx *,class QObject *)" (??0QOCIDriver@@QEAA@PEAUOCIEnv@@PEAUOCISvcCtx@@PEAVQObject@@@Z) 中被引用

都是同样的错误



你可能感兴趣的:(C)