QT enVocabulary工程打包問題記錄
我用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程式打包問題
執行程式,窗體含有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!