我用QT自带的工具*deployqt把工程enVocabulary在mac,windows,ubuntu上打包,出现了一些问题。
下面是一些bug记录。
sqlite MysqL的依赖问题。
WARNING: Plugin "libqsqlodbc.dylib" uses private API and is not Mac App store compliant.
WARNING: Plugin "libqsqlpsql.dylib" uses private API and is not Mac App store compliant.
ERROR: no file at "/opt/local/lib/MysqL55/MysqL/libMysqLclient.18.dylib"
ERROR: no file at "/usr/local/lib/libpq.5.dylib"
听说这是QT自身的bug,使用了sqlite则会需要用到MysqL的库文件,不用管。
直接macdeployqt走起。
运行程序,窗体含有QML的部分是空白的。
module "QtQuick.Window" is not installed
module "QtQuick.Controls" is not installed
module "QtQuick" is not installed
...
搜寻后,发现系统的QML路径是/Users/weiyang/Qt5.9.2/5.9.2/clang_64/qml
打包后已经有framework:./enVocabulary.app/Contents/Frameworks/QtQuick.framework
那是怎么回事儿?
在文件夹中搜寻qml文件:
weiyangdeMacBook-Air:enVocabulary weiyang$ find enVocabulary.app/ -name *qml
weiyangdeMacBook-Air:enVocabulary weiyang$
居然没有qml文件!
在stack overflow上找到相关的问题:https://stackoverflow.com/questions/17475788/qt-5-1-and-mac-bug-making-macdeployqt-not-working-properly/28221423#28221423
原来在使用macdeployqt打包的时候需要指定qml文件的地址。
也即:macdeployqt enVocabulary.app/ -qmldir=/Users/weiyang/code/enVocabulary -dmg
然后在enVocabulary.app//Contents/Resources/qml/
就能看到各种qml,qmlc文件了
之后,编译运行,一切正常!
No rule to make target
类似于这样的报错:
mingw32-make[1]: *** No rule to make target '../enVocabulary/image/res.rc',needed by 'OBJ/res_res.o'. Stop.
不一定是Makefile的问题,很有可能是根本没有文件../enVocabulary/image/res.rc
(名字写错了)
qt.network.ssl: QSslSocket: cannot resolve
我的程序使用了network相关的类,然后运行报错:
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_num_locks
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_set_id_callback
qt.network.ssl: QSslSocket: cannot resolve CRYPTO_set_locking_callback
qt.network.ssl: QSslSocket: cannot resolve ERR_free_strings
...
qt.network.ssl: QSslSocket: cannot resolve SSLv3_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv23_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
qt.network.ssl: QSslSocket: cannot resolve SSLv3_server_method
qt.network.ssl: QSslSocket: cannot resolve SSLv23_server_method
qt.network.ssl: QSslSocket: cannot resolve X509_STORE_CTX_get_chain
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot resolve SSLeay
qt.network.ssl: QSslSocket: cannot resolve SSLeay_version
当前的QT版本是5.9.2,我用代码打印SSL相关的信息:
qDebug()<<"SSL version use for build: "<<QSslSocket::sslLibraryBuildVersionString();
qDebug()<<"SSL version use for run-time: "<<QSslSocket::sslLibraryVersionString();
qDebug()<<QSslSocket::supportsSsl()<<endl;
qDebug()<<QCoreApplication::libraryPaths();
结果:
SSL version use for build: "OpenSSL 1.0.1e-fips 11 Feb 2013"
qt.network.ssl: Incompatible version of OpenSSL
SSL version use for run-time: ""
false
在stack overflow上一顿查询,什么重新下载openssl再编译,QT组件修复等方法都尝试了一遍,没用。
然后逛qt官网,希望最新版本的QT能解决这个问题。http://blog.qt.io/blog/2017/12/07/qt-5-10-released/
果然让我找到了相关的信息:
下载Qt5.10.1,安装后重新运行:
SSL version use for build: "OpenSSL 1.0.2k-fips 26 Jan 2017"
SSL version use for run-time: "OpenSSL 1.0.2g 1 Mar 2016"
true
但我在后面的log(考虑到容错性,我加了许多的DEBUG)中发现了新的问题:The issuer certificate of a locally looked up certificate could not be found
这是为什么?我在terminal中启动openssl,然后它提示找不到库文件,我将libcrypto.so,libssl.so相关的四个文件全部放进/usr/lib中,然后可以正常启动了。
parallels@parallels-vm:~/Downloads/openssl-1.1.1-pre4$ openssl version
OpenSSL 1.1.1-pre4 (beta) 3 Apr 2018
但是Qt运行报错:
SSL version use for build: "OpenSSL 1.0.2k-fips 26 Jan 2017"
...
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot resolve SSLeay
qt.network.ssl: Incompatible version of OpenSSL
...
qt.network.ssl: Incompatible version of OpenSSL
SSL version use for run-time: "" SSL version use for run-time:
false
版本不兼容,好烦。。。
参照之前的log,我下载了openssl 1.0.2g:https://www.openssl.org/source/old/1.0.2/
编译,安装,然后创建软连接:ln -s /home/parallels/Downloads/openssl-1.0.2g/apps/openssl /usr/local/bin/openssl
但是版本不兼容的错误仍然存在!回想自己是将libcrypto.so,libssl.so相关的四个文件全部放进/usr/lib中然后就出现了兼容性问题。我又将/usr/lib路径下的*crypto.so*
,*ssl.so*
的四个文件统统删除了。 然后运行,perfect!