QT6 Static Build error undefined reference to `SQLGetInfoW'
-
after finish building static and everything done
when i add qmysql codes and try to run the program
i see all this errors
this is compile static paramtercmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DBUILD_qtwebengine=OFF -DOPENSSL_ROOT_DIR="C:\OpenSSL\openssl-1.1.1i\static\x64\debug" -DOPENSSL_USE_STATIC_LIBS=TRUE -DOPENSSL_MSVC_STATIC_RT=TRUE -DINPUT_sql_mysql=ON -DMySQL_INCLUDE_DIRS="C:\2\include" -DMySQL_LIBRARIES="C:\2\lib\mysqlclient.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\static" -G Ninja C:\Qt\6.1.2\Src
also i add sql to my .pro file ```
QT += core gui sql
-
"When I add mysql codes", and a list of ODBC-related linker errors do not go together.
I guess your static libraries have the Qt ODBC driver included and your application link options do not include the relevant Windows ODBC driver link libraries (odbc32.lib I think).
-
QSqlDatabase db ;
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("hhostip");
db.setUserName("user");
db.setPassword("pass");
db.setDatabaseName("dbname");
if(db.open())
{
ui->textEdit->setText("Ok");
//db.close();
}
else {
ui->textEdit->setText("No");
db.close();
} -
Configure what ?
-
@SGaist
i mean the configure line of static buildcmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DBUILD_qtwebengine=OFF -DOPENSSL_ROOT_DIR="C:\OpenSSL\openssl-1.1.1i\static\x64\debug" -DOPENSSL_USE_STATIC_LIBS=TRUE -DOPENSSL_MSVC_STATIC_RT=TRUE -DINPUT_sql_mysql=ON -DMySQL_INCLUDE_DIRS="C:\2\include" -DMySQL_LIBRARIES="C:\2\lib\mysqlclient.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\static" -G Ninja C:\Qt\6.1.2\Src
-
I currently don't know if you can easily change that using cmake.
-
i tried this code to skip odbc sql
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DQT_BUILD_EXAMPLES=OFF -DINPUT_static_runtime=ON -DFEATURE_ltcg=OFF -DBUILD_qtwebengine=OFF -DINPUT_sql_odbc=OFF -DINPUT_sql_mysql=ON -DMySQL_INCLUDE_DIRS="C:\2\include" -DMySQL_LIBRARIES="C:\2\lib\mysqlclient.lib" -DMySQL_USE_STATIC_LIBS=TRUE -DCMAKE_INSTALL_PREFIX="C:\Qt\static" -G Ninja C:\Qt\6.1.2\Src
but doesn't work
-
And why not just modify the list of linked plugins like shown in the documentation I linked ?