Qt 6.3.1 painful....
-
I was previously building on my iMAC with Qt 5.12.3 today I ported to Qt 6.3.1 as I am now working on my new MacBook Pro M1, earlier versions of Qt do not support this machine.
However there is a lot that seems to have gone in Qt 6.3.1 I am working through these.
One of the issues I have now is I use QRegExp:
QRegExp rx("\\t|\\n"); strChanges = pobjCopy->strGetAttribute(strAttr); //Replace tabs and newlines with space QStringList slstChanges(strChanges .replace(rx, " ") .split(clsXMLnode::msccParamDelimiter));
This will not compile and the errors I get are:
/Users/simonplatten/XMLMPAM/clsMainWnd.cpp:5286: error: no matching member function for call to 'replace' ../clsMainWnd.cpp:5286:60: error: no matching member function for call to 'replace' QStringList slstChanges(strChanges.replace(rx, " ") ~~~~~~~~~~~^~~~~~~ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:688:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'QLatin1String' for 1st argument QString &replace(QLatin1String before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:690:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'const QString' for 1st argument QString &replace(const QString &before, const QString &after, ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:692:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'QChar' for 1st argument QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:695:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'const QRegularExpression' for 1st argument QString &replace(const QRegularExpression &re, const QString &after); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:685:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'QChar' for 1st argument QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:687:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'QLatin1String' for 1st argument QString &replace(QLatin1String before, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:689:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'const QString' for 1st argument QString &replace(const QString &before, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:693:14: note: candidate function not viable: no known conversion from 'QRegExp' to 'QChar' for 1st argument QString &replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:682:14: note: candidate function not viable: requires 3 arguments, but 2 were provided QString &replace(qsizetype i, qsizetype len, QChar after); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:684:14: note: candidate function not viable: requires 3 arguments, but 2 were provided QString &replace(qsizetype i, qsizetype len, const QString &after); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:683:14: note: candidate function not viable: requires 4 arguments, but 2 were provided QString &replace(qsizetype i, qsizetype len, const QChar *s, qsizetype slen); ^ ../../Qt/6.3.1/macos/lib/QtCore.framework/Headers/qstring.h:686:14: note: candidate function not viable: requires at least 4 arguments, but 2 were provided QString &replace(const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive); ^
-
Don't go from 5.12 to 6.x but from 5.12 to 5.15, remove all the deprecation warnings and then go to 6.x.
QRegExp is deprecated since ages (a.k.a since Qt5.0)... -
Don't go from 5.12 to 6.x but from 5.12 to 5.15, remove all the deprecation warnings and then go to 6.x.
QRegExp is deprecated since ages (a.k.a since Qt5.0)...@Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.
-
Then go with the latest Qt6. Too many changes in Qt6. Personally, I would wait a few more months to touch Qt6.
-
@Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.
@SPlatten you could use a virtual machine with linux and do the latest qt5 deprecation removal there. Than either move back to mac and finish the qt6 port or continue on linux until you have a running version. That should be the quickest and most painless approach IMHO.
-
@SPlatten you could use a virtual machine with linux and do the latest qt5 deprecation removal there. Than either move back to mac and finish the qt6 port or continue on linux until you have a running version. That should be the quickest and most painless approach IMHO.
@DerReisende , thank you, its not a race to get it finished, I just want to get the Qt 6.3.1 version building on the MacBook Pro.
-
@DerReisende , thank you, its not a race to get it finished, I just want to get the Qt 6.3.1 version building on the MacBook Pro.
-
@Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.
@SPlatten said in Qt 6.3.1 painful....:
because the target is an Apple M1.
So you want to tell me you can compile your program with Qt5.12 but not with Qt5.15? Nice try...
-
@SPlatten said in Qt 6.3.1 painful....:
because the target is an Apple M1.
So you want to tell me you can compile your program with Qt5.12 but not with Qt5.15? Nice try...
@Christian-Ehrlicher , if I was working on my iMAC its not a problem as that's an i7, as I said I am now working on my MacBook Pro M1.
-
Still trying to fix this, in my pro file I have:
#------------------------------------------------- # # Project created by QtCreator 2018-10-15T09:17:31 # #------------------------------------------------- QT += core network gui qml sql greaterThan(QT_MAJOR_VERSION, 4): QT += svg widgets greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat statemachine svgwidgets TARGET = XMLMPAM TEMPLATE = app # Uncomment to include XML debug information #DEFINES += DEBUG_JSON DEFINES += DEBUG_LAUNCHER DEFINES += DEBUG_MODULES #DEFINES += DEBUG_SOCKETS DEFINES += DEBUG_SCRIPT DEFINES += DEBUG_SIGNALS #DEFINES += DEBUG_THREADS #DEFINES += DEBUG_XML ####### Custom Variables EXPORT_QMAKE_MAC_SDK = macosx EXPORT_QMAKE_MAC_SDK_VERSION = 10.15 EXPORT_VALID_ARCHS = x86_64 # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # Added when porting to Qt 6 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 CONFIG += console CONFIG += sdk_no_version_check CONFIG += app_bundle CONFIG += QT_DEBUG_PLUGINS #CONFIG += qml_debug SOURCES += \ clsCNT.cpp \ clsDebugService.cpp \ clsFileThread.cpp \ clsJSON.cpp \ clsListener.cpp \ clsMainWnd.cpp \ clsModule.cpp \ clsQtCheckBox.cpp \ clsQtComboBox.cpp \ clsQtFrame.cpp \ clsQtJsonStack.cpp \ clsQtLabel.cpp \ clsQtLayout.cpp \ clsQtLineEdit.cpp \ clsQtListWidget.cpp \ clsQtPushBtn.cpp \ clsQtRadioButton.cpp \ clsQtSlider.cpp \ clsQtTextEdit.cpp \ clsSignal.cpp \ clsScriptHelper.cpp \ clsThread.cpp \ XMLMPAM.cpp HEADERS += \ clsCNT.h \ clsDebugService.h \ clsJSON.h \ clsListener.h \ clsMainWnd.h \ clsFileThread.h \ clsModule.h \ clsQtCheckBox.h \ clsQtComboBox.h \ clsQtFrame.h \ clsQtJsonStack.h \ clsQtLabel.h \ clsQtLayout.h \ clsQtLineEdit.h \ clsQtListWidget.h \ clsQtPushBtn.h \ clsQtRadioButton.h \ clsQtSlider.h \ clsQtTextEdit.h \ clsScriptHelper.h \ clsSignal.h \ clsThread.h FORMS += \ clsMainWnd.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ clsmainwnd.qrc DISTFILES += \ config/form.xml \ config/form2.xml \ config/simon.js \ config/simon.xml \ config/simon2.js \ config/xmlmpam.xml
Just spotted:
EXPORT_QMAKE_MAC_SDK = macosx EXPORT_QMAKE_MAC_SDK_VERSION = 10.15 EXPORT_VALID_ARCHS = x86_64
Could these be a problem on the MacBook Pro M1 ?
Have modified pro file for apple M1 build:
EXPORT_VALID_ARCHS = arm64
Building now...how can I add a conditional argument to build for either x86_64 on iMAC or arm64 on macBook Pro M1 ?
-
Still trying to fix this, in my pro file I have:
#------------------------------------------------- # # Project created by QtCreator 2018-10-15T09:17:31 # #------------------------------------------------- QT += core network gui qml sql greaterThan(QT_MAJOR_VERSION, 4): QT += svg widgets greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat statemachine svgwidgets TARGET = XMLMPAM TEMPLATE = app # Uncomment to include XML debug information #DEFINES += DEBUG_JSON DEFINES += DEBUG_LAUNCHER DEFINES += DEBUG_MODULES #DEFINES += DEBUG_SOCKETS DEFINES += DEBUG_SCRIPT DEFINES += DEBUG_SIGNALS #DEFINES += DEBUG_THREADS #DEFINES += DEBUG_XML ####### Custom Variables EXPORT_QMAKE_MAC_SDK = macosx EXPORT_QMAKE_MAC_SDK_VERSION = 10.15 EXPORT_VALID_ARCHS = x86_64 # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # Added when porting to Qt 6 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG += c++11 CONFIG += console CONFIG += sdk_no_version_check CONFIG += app_bundle CONFIG += QT_DEBUG_PLUGINS #CONFIG += qml_debug SOURCES += \ clsCNT.cpp \ clsDebugService.cpp \ clsFileThread.cpp \ clsJSON.cpp \ clsListener.cpp \ clsMainWnd.cpp \ clsModule.cpp \ clsQtCheckBox.cpp \ clsQtComboBox.cpp \ clsQtFrame.cpp \ clsQtJsonStack.cpp \ clsQtLabel.cpp \ clsQtLayout.cpp \ clsQtLineEdit.cpp \ clsQtListWidget.cpp \ clsQtPushBtn.cpp \ clsQtRadioButton.cpp \ clsQtSlider.cpp \ clsQtTextEdit.cpp \ clsSignal.cpp \ clsScriptHelper.cpp \ clsThread.cpp \ XMLMPAM.cpp HEADERS += \ clsCNT.h \ clsDebugService.h \ clsJSON.h \ clsListener.h \ clsMainWnd.h \ clsFileThread.h \ clsModule.h \ clsQtCheckBox.h \ clsQtComboBox.h \ clsQtFrame.h \ clsQtJsonStack.h \ clsQtLabel.h \ clsQtLayout.h \ clsQtLineEdit.h \ clsQtListWidget.h \ clsQtPushBtn.h \ clsQtRadioButton.h \ clsQtSlider.h \ clsQtTextEdit.h \ clsScriptHelper.h \ clsSignal.h \ clsThread.h FORMS += \ clsMainWnd.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ clsmainwnd.qrc DISTFILES += \ config/form.xml \ config/form2.xml \ config/simon.js \ config/simon.xml \ config/simon2.js \ config/xmlmpam.xml
Just spotted:
EXPORT_QMAKE_MAC_SDK = macosx EXPORT_QMAKE_MAC_SDK_VERSION = 10.15 EXPORT_VALID_ARCHS = x86_64
Could these be a problem on the MacBook Pro M1 ?
Have modified pro file for apple M1 build:
EXPORT_VALID_ARCHS = arm64
Building now...how can I add a conditional argument to build for either x86_64 on iMAC or arm64 on macBook Pro M1 ?
@SPlatten , I'm struggling to understand by the application crashes on start-up when run on the MacBook Pro m1, it doesn't on the iMAC.
Its very difficult to debug because it halts in qarraydata on line 178 but the debug locals area only contains:
[statics] None allocSize. <not accessible> header. 0x0
Can anyone suggest how I might fault find this problem?
There is a problem report but its two large to post.
-
@SPlatten , I'm struggling to understand by the application crashes on start-up when run on the MacBook Pro m1, it doesn't on the iMAC.
Its very difficult to debug because it halts in qarraydata on line 178 but the debug locals area only contains:
[statics] None allocSize. <not accessible> header. 0x0
Can anyone suggest how I might fault find this problem?
There is a problem report but its two large to post.
@SPlatten In another thread here I mentioned architectural differences of Apple Silicon to intel which may cause working intel code to crash when compiled for Apple Silicon. Apple suggests in this video to use thread sanitizer etc to hunt for those bugs in your code. If your x86 app runs without problems using Rosetta but crashes when compiled as apple native then you may have one of the problems described in the video. It might worth a shot compiling and running your app with various sanitizer options.
-
@SPlatten In another thread here I mentioned architectural differences of Apple Silicon to intel which may cause working intel code to crash when compiled for Apple Silicon. Apple suggests in this video to use thread sanitizer etc to hunt for those bugs in your code. If your x86 app runs without problems using Rosetta but crashes when compiled as apple native then you may have one of the problems described in the video. It might worth a shot compiling and running your app with various sanitizer options.
@DerReisende , thank you, I will go take a look.
-
@DerReisende , thank you, I will go take a look.
-
@DerReisende , how or where do I get the version to assign to EXPORT_QMAKE_MAC_SDK_VERSION ?
[Edit] Is this the version displayed when running Xcode ? In my case 13.4.1
[Edit2] My project still crashes in qarraydata on line 178, `I'm wondering if there is an issue with the type long long as Qt Creator does not show the value associated with allocSize which is of type long long ? -
@DerReisende , how or where do I get the version to assign to EXPORT_QMAKE_MAC_SDK_VERSION ?
[Edit] Is this the version displayed when running Xcode ? In my case 13.4.1
[Edit2] My project still crashes in qarraydata on line 178, `I'm wondering if there is an issue with the type long long as Qt Creator does not show the value associated with allocSize which is of type long long ?@SPlatten I am not sure if QMAKE_MAC_SDK_VERSION is the correct way to set the macos minimum sdk version during compilation. But I have to admit that I dont use qmake. A quick search gave me this thread which may be more correct to specify the target sdk for compilation.
Did you compile and run the project with
-fsanitize=thread
compiler option`? -
@SPlatten I am not sure if QMAKE_MAC_SDK_VERSION is the correct way to set the macos minimum sdk version during compilation. But I have to admit that I dont use qmake. A quick search gave me this thread which may be more correct to specify the target sdk for compilation.
Did you compile and run the project with
-fsanitize=thread
compiler option`?@DerReisende Thank you, I want to keep using the .pro file if possible so I will look for a MIN version of the directive.
-
I'm not sure I am winning this battle Qt 6.3.1 on my MacBook Pro Apple M1 is not going anywhere fast.
My application is multi-threaded, when I run the application it is halting in (__pthread_kill) showing a window containing nothing but hex, the stack trade showing in Test Results panel contains:
1 __pthread_kill (arm64e) /usr/lib/system/libsystem_kernel.dylib 0x185b2ed98 2 pthread_kill (arm64e) /usr/lib/system/libsystem_pthread.dylib 0x185b63ee0 3 abort (arm64e) /usr/lib/system/libsystem_c.dylib 0x185a9e340 4 malloc_vreport (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x1859808c0 5 malloc_zone_error (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x185995c84 6 nanov2_allocate_from_block (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x185972bc4 7 nanov2_allocate (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x1859721e0 8 nanov2_calloc (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x18597437c 9 _malloc_zone_calloc (arm64e) /usr/lib/system/libsystem_malloc.dylib 0x18598f840 10 class_createInstance (arm64e) /usr/lib/libobjc.A.dylib 0x1859ea404 11 _os_object_alloc_realized (arm64e) /usr/lib/system/libdispatch.dylib 0x18599f568 12 _xpc_dictionary_deserialize (arm64e) /usr/lib/system/libxpc.dylib 0x1858982d0 13 _xpc_array_deserialize (arm64e) /usr/lib/system/libxpc.dylib 0x1858981ec 14 _xpc_dictionary_unpack_value (arm64e) /usr/lib/system/libxpc.dylib 0x185893fc0 15 _xpc_dictionary_unpack_value_and_vend (arm64e) /usr/lib/system/libxpc.dylib 0x185895424 16 _xpc_dictionary_look_up (arm64e) /usr/lib/system/libxpc.dylib 0x18588fe8c 17 -[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:] (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x185be46a4 18 __80-[CFPrefsSearchListSource alreadylocked_generationCountFromListOfSources:count:]_block_invoke (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x185be45a8 19 __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke_2 (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x185be4540 20 -[_CFXPreferences withConnectionForRole:performBlock:] (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x185be4100 21 __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x185be40a4 22 _dispatch_client_callout2 (arm64e) /usr/lib/system/libdispatch.dylib 0x1859a01f4 23 _dispatch_apply_invoke (arm64e) /usr/lib/system/libdispatch.dylib 0x1859b3954 24 _dispatch_client_callout (arm64e) /usr/lib/system/libdispatch.dylib 0x1859a01b4 25 _dispatch_root_queue_drain (arm64e) /usr/lib/system/libdispatch.dylib 0x1859b1a04 26 _dispatch_worker_thread2 (arm64e) /usr/lib/system/libdispatch.dylib 0x1859b2104 27 _pthread_wqthread (arm64e) /usr/lib/system/libsystem_pthread.dylib 0x185b60324
-
I guess you are able to use c++20 now. Adding logging code into your threads may enable you to find issues more quickly.
https://mariusbancila.ro/blog/2021/07/03/writing-a-simple-logging-function-in-c20/