Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building qgis with Qt6 on Windows #57002

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/mingw-w64-msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
10 changes: 7 additions & 3 deletions cmake/SIPMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions external/mdal/mdal_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,12 +1113,12 @@ std::vector<std::string> MDAL::Library::libraryFilesInDir( const std::string &di
{
std::vector<std::string> 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;
Expand All @@ -1129,7 +1129,7 @@ std::vector<std::string> 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
Expand Down Expand Up @@ -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 );
Expand Down
10 changes: 5 additions & 5 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/app/mainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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;
Expand Down Expand Up @@ -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<BOOL( * )( DWORD )>( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0;
DLL_DIRECTORY_COOKIE( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast<DLL_DIRECTORY_COOKIE( * )( PCWSTR )>( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0;
#ifndef _MSC_VER // MinGW
Expand Down Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsattributetableconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsopenclutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 )
Expand Down Expand Up @@ -155,15 +155,15 @@ 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' ) )
.arg( d );

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 )
{
Expand Down
Loading