From 2385fdf7c4bc4e6567cfbba67e9b3fc9b5e47562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sat, 11 Mar 2023 05:41:40 +0000 Subject: [PATCH 1/5] Fix building with Qt6 on Windows Use ANSI functions. --- src/app/main.cpp | 10 +++++----- src/app/mainwin.cpp | 14 +++++++------- src/app/qgisapp.cpp | 2 +- src/core/qgsopenclutils.cpp | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 92d7c591946a..5d1746945c76 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -177,10 +177,10 @@ void usage( const QString &appName ) << QStringLiteral( " the PostGIS extension\n" ) ; // OK #ifdef Q_OS_WIN - MessageBox( nullptr, - msg.join( QString() ).toLocal8Bit().constData(), - "QGIS command line options", - MB_OK ); + MessageBoxA( nullptr, + msg.join( QString() ).toLocal8Bit().constData(), + "QGIS command line options", + MB_OK ); #else std::cout << msg.join( QString() ).toLocal8Bit().constData(); #endif @@ -219,7 +219,7 @@ void myPrint( const char *fmt, ... ) #if defined(Q_OS_WIN) char buffer[1024]; vsnprintf( buffer, sizeof buffer, fmt, ap ); - OutputDebugString( buffer ); + OutputDebugStringA( buffer ); #else vfprintf( stderr, fmt, ap ); #endif diff --git a/src/app/mainwin.cpp b/src/app/mainwin.cpp index c90ef7cc88f4..813f3b484aa9 100644 --- a/src/app/mainwin.cpp +++ b/src/app/mainwin.cpp @@ -24,7 +24,7 @@ void showError( std::string message, std::string title ) { std::string newmessage = "Oops, looks like an error loading QGIS \n\n Details: \n\n" + message; - MessageBox( + MessageBoxA( NULL, newmessage.c_str(), title.c_str(), @@ -40,7 +40,7 @@ std::string moduleExeBaseName( void ) for ( ;; ) { filepath.reset( new char[l] ); - if ( GetModuleFileName( nullptr, filepath.get(), l ) < l ) + if ( GetModuleFileNameA( nullptr, filepath.get(), l ) < l ) break; l += MAX_PATH; @@ -132,7 +132,7 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST #ifndef _MSC_VER // MinGW #pragma GCC diagnostic ignored "-Wcast-function-type" #endif - HINSTANCE hKernelDLL = LoadLibrary( "kernel32.dll" ); + HINSTANCE hKernelDLL = LoadLibraryA( "kernel32.dll" ); BOOL ( *SetDefaultDllDirectories )( DWORD ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0; DLL_DIRECTORY_COOKIE( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0; #ifndef _MSC_VER // MinGW @@ -171,20 +171,20 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST HINSTANCE hGetProcIDDLL = LoadLibrary( "qgis_app.dll" ); #else // MinGW - HINSTANCE hGetProcIDDLL = LoadLibrary( "libqgis_app.dll" ); + HINSTANCE hGetProcIDDLL = LoadLibraryA( "libqgis_app.dll" ); #endif if ( !hGetProcIDDLL ) { DWORD error = GetLastError(); - LPTSTR errorText = NULL; + LPSTR errorText = NULL; - FormatMessage( + FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), - ( LPTSTR )&errorText, + ( LPSTR )&errorText, 0, NULL ); diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 3b36ea2c3a43..86c93abe97fe 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -13038,7 +13038,7 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory ) CFRelease( urlRef ); #elif defined(Q_OS_WIN) if ( url.startsWith( "file://", Qt::CaseInsensitive ) ) - ShellExecute( 0, 0, url.mid( 7 ).toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL ); + ShellExecuteA( 0, 0, url.mid( 7 ).toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL ); else QDesktopServices::openUrl( url ); #else diff --git a/src/core/qgsopenclutils.cpp b/src/core/qgsopenclutils.cpp index 39fab282a0d0..d17e9baebfe0 100644 --- a/src/core/qgsopenclutils.cpp +++ b/src/core/qgsopenclutils.cpp @@ -100,7 +100,7 @@ void QgsOpenClUtils::init() } #ifdef Q_OS_WIN - HMODULE hModule = GetModuleHandle( "OpenCL.dll" ); + HMODULE hModule = GetModuleHandleA( "OpenCL.dll" ); if ( hModule ) { TCHAR pszFileName[1024]; @@ -114,13 +114,13 @@ void QgsOpenClUtils::init() DWORD dwLen = GetFileVersionInfoSize( pszFileName, &dwUseless ); if ( dwLen ) { - LPTSTR lpVI = ( LPSTR ) malloc( dwLen ); + LPSTR lpVI = ( LPSTR ) malloc( dwLen ); if ( lpVI ) { if ( GetFileVersionInfo( pszFileName, 0, dwLen, lpVI ) ) { VS_FIXEDFILEINFO *lpFFI; - if ( VerQueryValue( lpVI, "\\", ( LPVOID * ) &lpFFI, ( UINT * ) &dwUseless ) ) + if ( VerQueryValueA( lpVI, "\\", ( LPVOID * ) &lpFFI, ( UINT * ) &dwUseless ) ) { QgsMessageLog::logMessage( QObject::tr( "OpenCL Product version: %1.%2.%3.%4" ) .arg( lpFFI->dwProductVersionMS >> 16 ) @@ -155,7 +155,7 @@ void QgsOpenClUtils::init() << QStringLiteral( "SpecialBuild" ); for ( auto d : items ) { - LPTSTR lpBuffer; + LPSTR lpBuffer; QString subBlock = QString( QStringLiteral( "\\StringFileInfo\\%1%2\\%3" ) ) .arg( lpTranslate[0].wLanguage, 4, 16, QLatin1Char( '0' ) ) .arg( lpTranslate[0].wCodePage, 4, 16, QLatin1Char( '0' ) ) @@ -163,7 +163,7 @@ void QgsOpenClUtils::init() QgsDebugMsgLevel( QString( "d:%1 subBlock:%2" ).arg( d ).arg( subBlock ), 2 ); - BOOL r = VerQueryValue( lpVI, subBlock.toUtf8(), ( LPVOID * )&lpBuffer, ( UINT * )&dwUseless ); + BOOL r = VerQueryValueA( lpVI, subBlock.toUtf8(), ( LPVOID * )&lpBuffer, ( UINT * )&dwUseless ); if ( r && lpBuffer && lpBuffer != INVALID_HANDLE_VALUE && dwUseless < 1023 ) { From 2a51e922f5be698728c7c0061bf0d20f7884a64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sat, 11 Mar 2023 05:43:47 +0000 Subject: [PATCH 2/5] Export explicitly a function not exported on MinGW For some reason this function wasn't exportd with Both gcc/ld and clang/lld. --- src/core/qgsattributetableconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/qgsattributetableconfig.h b/src/core/qgsattributetableconfig.h index ba50862a3312..6b29b177e900 100644 --- a/src/core/qgsattributetableconfig.h +++ b/src/core/qgsattributetableconfig.h @@ -54,7 +54,7 @@ class CORE_EXPORT QgsAttributeTableConfig ColumnConfig() = default; // TODO c++20 - replace with = default - bool operator== ( const QgsAttributeTableConfig::ColumnConfig &other ) const SIP_SKIP; + bool CORE_EXPORT operator== ( const QgsAttributeTableConfig::ColumnConfig &other ) const SIP_SKIP; //! The type of this column. QgsAttributeTableConfig::Type type = Field; From 4d2ba5540abca5a3d01eeae8770cb14eba253de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sat, 11 Mar 2023 05:44:33 +0000 Subject: [PATCH 3/5] Fix building internl mdal with Qt6 on Windows --- external/mdal/mdal_utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/external/mdal/mdal_utils.cpp b/external/mdal/mdal_utils.cpp index efcbc1b6489a..38226deff850 100644 --- a/external/mdal/mdal_utils.cpp +++ b/external/mdal/mdal_utils.cpp @@ -1113,12 +1113,12 @@ std::vector MDAL::Library::libraryFilesInDir( const std::string &di { std::vector filesList; #ifdef _WIN32 - WIN32_FIND_DATA data; + WIN32_FIND_DATAA data; HANDLE hFind; std::string pattern = dirPath; pattern.push_back( '*' ); - hFind = FindFirstFile( pattern.c_str(), &data ); + hFind = FindFirstFileA( pattern.c_str(), &data ); if ( hFind == INVALID_HANDLE_VALUE ) return filesList; @@ -1129,7 +1129,7 @@ std::vector MDAL::Library::libraryFilesInDir( const std::string &di if ( !fileName.empty() && fileExtension( fileName ) == ".dll" ) filesList.push_back( fileName ); } - while ( FindNextFile( hFind, &data ) != 0 ); + while ( FindNextFileA( hFind, &data ) != 0 ); FindClose( hFind ); #else @@ -1160,7 +1160,7 @@ bool MDAL::Library::loadLibrary() #ifdef _WIN32 UINT uOldErrorMode = SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS ); - d->mLibrary = LoadLibrary( d->mLibraryFile.c_str() ); + d->mLibrary = LoadLibraryA( d->mLibraryFile.c_str() ); SetErrorMode( uOldErrorMode ); #else d->mLibrary = dlopen( d->mLibraryFile.c_str(), RTLD_LAZY ); From 9986ffe7f1b60f72c651ee76f5e14c3c70d18c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sun, 18 Feb 2024 16:24:53 +0000 Subject: [PATCH 4/5] CI: Test against Qt6 --- .github/workflows/mingw-w64-msys2.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/mingw-w64-msys2.yml b/.github/workflows/mingw-w64-msys2.yml index 9c6d2f1429e6..f4f0b2c183a1 100644 --- a/.github/workflows/mingw-w64-msys2.yml +++ b/.github/workflows/mingw-w64-msys2.yml @@ -49,9 +49,10 @@ jobs: install: base-devel pacboy: >- draco:p exiv2:p gdal:p gsl:p hdf5:p libxml2:p libzip:p netcdf:p opencl-icd:p pdal:p - protobuf:p proj:p qca-qt5:p qscintilla-qt5:p qt5-3d:p qt5-base:p qt5-declarative:p - qt5-gamepad:p qt5-location:p qt5-serialport:p qt5-svg:p qtkeychain-qt5:p qtwebkit:p - qwt-qt5:p spatialindex:p cc:p cmake:p ninja:p opencl-clhpp:p qt5-tools:p python:p ccache:p + protobuf:p proj:p qca-qt6:p qscintilla-qt6:p qt6-3d:p qt6-base:p qt6-declarative:p + qt6-location:p qt6-multimedia:p qt6-serialport:p qt6-svg:p qtkeychain-qt6:p qwt-qt6:p + spatialindex:p python-pyqt6:p python-gdal:p python-owslib:p python-qscintilla-qt6:p + cc:p cmake:p ninja:p opencl-clhpp:p qt6-tools:p ccache:p pyqt-builder:p update: true release: false @@ -68,16 +69,17 @@ jobs: CXXFLAGS="-DQWT_POLAR_VERSION=0x060200" \ cmake \ -G"Ninja" \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DPython_EXECUTABLE=${MINGW_PREFIX}/bin/python \ -DWITH_3D=ON \ -DWITH_DRACO=ON \ -DWITH_PDAL=OFF \ -DWITH_CUSTOM_WIDGETS=ON \ -DWITH_QWTPOLAR=OFF \ - -DWITH_BINDINGS=OFF \ + -DWITH_BINDINGS=ON \ -DWITH_GRASS=OFF \ -DUSE_CCACHE=ON \ + -DBUILD_WITH_QT6=ON \ + -DWITH_QTWEBKIT=OFF \ -S . \ -B build From 0f44e4daafb3d57ca4a8919f801ab8f48ee91704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?= =?UTF-8?q?=20=28Mehdi=20Chinoune=29?= Date: Sun, 18 Feb 2024 19:48:39 +0000 Subject: [PATCH 5/5] Fix compilation of large objects on MinGW --- cmake/SIPMacros.cmake | 10 +++++++--- src/core/CMakeLists.txt | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cmake/SIPMacros.cmake b/cmake/SIPMacros.cmake index 24426130e930..14f96be4c518 100644 --- a/cmake/SIPMacros.cmake +++ b/cmake/SIPMacros.cmake @@ -87,9 +87,13 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP SIP_FILES CPP_FILES ENDIF(MSVC) ENDIF(PEDANTIC) - IF(MSVC) - ADD_DEFINITIONS( /bigobj ) - ENDIF(MSVC) + IF(WIN32) + IF(MSVC) + ADD_DEFINITIONS( /bigobj ) + ELSE() + ADD_DEFINITIONS( -Wa,-mbig-obj ) + ENDIF() + ENDIF() IF (SIP_BUILD_EXECUTABLE) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c2a907fd1067..489f11db2270 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2102,13 +2102,22 @@ if (HAVE_WEBENGINE) ) endif() -if(MSVC) - set_source_files_properties( +if(WIN32) + if(MSVC) + set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp ${CMAKE_CURRENT_BINARY_DIR}/qgis_core_autogen/mocs_compilation.cpp proj/qgscoordinatereferencesystem.cpp PROPERTIES COMPILE_FLAGS "/bigobj" - ) + ) + else() + set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp + ${CMAKE_CURRENT_BINARY_DIR}/qgis_core_autogen/mocs_compilation.cpp + proj/qgscoordinatereferencesystem.cpp + PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj" + ) + endif() else() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp PROPERTIES COMPILE_FLAGS "-O1")