Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. "unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked)" (Qt6, Mac)
Qt 6.11 is out! See what's new in the release blog

"unsupported mach-o filetype (only MH_OBJECT and MH_DYLIB can be linked)" (Qt6, Mac)

Scheduled Pinned Locked Moved Unsolved Qt 6
4 Posts 2 Posters 122 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SprezzaturaS Offline
    SprezzaturaS Offline
    Sprezzatura
    wrote last edited by
    #1

    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.dylib
    

    QTDIR resolves to:

    /Users/me/Qt6/6.11.1/macos
    

    I 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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      What is done with these .pro file variables you create ?

      On a side note, did you consider moving to cmake as well ? qmake is deprecated (but still supported).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • SprezzaturaS Offline
        SprezzaturaS Offline
        Sprezzatura
        wrote last edited by Sprezzatura
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by SGaist
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved