• 8685阅读
  • 2回复

[提问]qt编译mysql。。 [复制链接]

上一主题 下一主题
离线xxl104
 
只看楼主 倒序阅读 楼主  发表于: 2011-05-31


第一次发帖,希望各位大牛指导
我用的qt是基于Qt 4.6.2的Qt Creator 1.3.1 Windows版本,mysql是mysql-essential-5.1.44-win32 。刚开始完全是按照yafeilinux那个做的(http://hi.baidu.com/yafeilinux/blog/item/c895e723f474e0f8d6cae22b.html
可最后执行mingw32-make 就不行了,
出现了
../../../sql/drivers/mysql/qsql_mysql.h:47:19: mysql.h: No such file or director
y
In file included from main.cpp:39:
../../../sql/drivers/mysql/qsql_mysql.h:98: error: expected `)' before '*' token
mingw32-make[1]: *** [tmp/obj/release_shared/main.o] Error 1
mingw32-make[1]: Leaving directory `D:/Qt/4.3.3/src/plugins/sqldrivers/mysql'
mingw32-make: *** [release] Error 2
我用creator打开这个工程(提示错误的那两行都有下划线,我想可能是输入法导致的),经过多次修改,最后这两个问题没了,可还是不行
E:\Qt\2010.02.1\qt\src\plugins\sqldrivers\mysql>mingw32-make
e:\Qt\2010.02.1\qt\bin\qmake.exe -win32 INCLUDEPATH+=C:\MYSQL\INCLUDE LIBS+=C:\M
YSQL\LIB\OPT\LIBMYSQL.a -o Makefile mysql.pro
mingw32-make -f Makefile.Debug all
mingw32-make[1]: Entering directory `E:/Qt/2010.02.1/qt/src/plugins/sqldrivers/m
ysql'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -shared -Wl,--out-implib,e:\Qt\2010.02.1\qt\plugins\sqldrivers\
libqsqlmysqld4.a -o ..\..\..\..\plugins\sqldrivers\qsqlmysqld4.dll tmp/obj/debug
_shared/main.o tmp/obj/debug_shared/qsql_mysql.o tmp/obj/debug_shared/moc_qsql_m
ysql.o  -L"e:\Qt\2010.02.1\qt\lib" -L"e:\Qt\2010.02.1\qt\lib" tmp\obj\debug_shar
ed\qsqlmysqld_resource_res.o C:\MYSQL\LIB\OPT\LIBMYSQL.a -llibmysql E:/Qt/2010.0
2.1/qt/src/plugins/sqldrivers/mysql/libmysql.a -lQtSqld4 -lQtCored4
e:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.ex
e: cannot find -llibmysql
collect2: ld returned 1 exit status
mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlmysqld4.dll] Error 1
mingw32-make[1]: Leaving directory `E:/Qt/2010.02.1/qt/src/plugins/sqldrivers/my
sql'
mingw32-make: *** [debug-all] Error 2
无奈之下,我google搜到了http://apps.hi.baidu.com/share/detail/34835376http://blog.csdn.net/dfman1978/archive/2008/10/16/3082326.aspx这两篇文章
,可以看出这两篇文章前边的说法都比较一致,可最后的命令就不一样了:一个是make。一个是mingw32-make(原文应该少个w吧),菜鸟的我又照他们说的都做了一遍,可结果make时提示make不是内部或外部命令。。。而mingw32-make时和原来yafeilinux文章中的mingw32-make错误完全相同。最后打开Qt Creator帮助:
How to Build the QMYSQL Plugin on Windows
You need to get the MySQL installation files. Run SETUP.EXE and choose "Custom Install". Install the "Libs & Include Files" Module. Build the plugin as follows (here it is assumed that MySQL is installed in C:\MySQL):
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
nmake
If you are not using a Microsoft compiler, replace nmake with make in the line above.
我又nmake,提示nmake不是内部或外部命令,实在不知怎么办。。。。请各位大哥帮帮忙,还有到底用不用生成libmysql.a?另外我想请教一下qt的版本与mysql版本之间的要求(是不是在发行日期上qt的应该比mysql的晚才能编译
离线xxl104
只看该作者 1楼 发表于: 2011-05-31
怎么没人发表看法啊
离线xxl104
只看该作者 2楼 发表于: 2011-06-01
哎。。。。。等了半天,还是自食其力吧
http://www2.gliet.edu.cn/qrs/news_view.asp?id=126&type_id=4
快速回复
限100 字节
 
上一个 下一个