"unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked)" (Qt6, Mac)
-
I am converting a project from Qt5 to Qt6.11 on the Mac.
My .PRO file specifies:QT += core gui help uitools widgets printsupport network xml sql Platforms.files += $$(QTDIR)/plugins/platforms/libqcocoa.dylib Styles.files += $$(QTDIR)/plugins/styles/libqmacstyle.dylib Imageformats.files += $$(QTDIR)/plugins/imageformats/libqico.dylib \ $$(QTDIR)/plugins/imageformats/libqgif.dylib \ $$(QTDIR)/plugins/imageformats/libqjpeg.dylib \ $$(QTDIR)/plugins/imageformats/libqsvg.dylibQTDIR resolves to:
/Users/me/Qt6/6.11.1/macosI am getting the errors:
unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/platforms/libqcocoa.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/imageformats/libqico.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/styles/libqmacstyle.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/imageformats/libqgif.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/imageformats/libqjpeg.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/imageformats/libqsvg.dylib' unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked) in '../MyApp.app/Contents/Plugins/sqldrivers/libqsqlite.dylib'Why is Qt objecting to its own DLLs? I delete the MyApp.app folder before compiling. It is built during the compilation step, presumably the .dylib's are drawn from QTDIR?
Can you help get this thing to link?
-
Hi,
What is done with these
.profile variables you create ?On a side note, did you consider moving to cmake as well ? qmake is deprecated (but still supported).
-
I asked ChatGPT and the solution was to remove the following lines from the .PRO file:
PrintSupport.files += $$(QTDIR)/plugins/printsupport/libcocoaprintersupport.dylib PrintSupport.path = Contents/Plugins/printsupport Platforms.path = Contents/Plugins/platforms Platforms.files += $$(QTDIR)/plugins/platforms/libqcocoa.dylib Styles.path = Contents/Plugins/styles Styles.files += $$(QTDIR)/plugins/styles/libqmacstyle.dylib Imageformats.path = Contents/Plugins/imageformats -L"MyApp.app/Contents/Plugins/platforms" -lqcocoa \CharGPT warned me that:
"Under Qt6 on macOS, the plugin binaries are no longer ordinary .dylib files"
"let Qt deploy the plugins."
"Your linker is explicitly trying to link the plugins into the executable."My experience is primarily Windows, I don't know much about macOS.
I would dearly love to migrate to CMake. I even started doing it, using a utility to convert the .PRO to CMakeLists.txt. But the errors I am getting are incomprehensible. I've got so many irons in the fire, I just have to put this on the back burner until I can devote all the time it's going to require to deal with it.
-
The thing is (even if it somehow worked before): you don't link dynamic plugins. They are loaded at run time but are not linked into your binary.
I can totally relate to not doing a build system migration at the same time as a gazillion other things more pressing.