Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to change sysroot in macOS?

How to change sysroot in macOS?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
2 Posts 1 Posters 1.8k 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.
  • Guy GizmoG Offline
    Guy GizmoG Offline
    Guy Gizmo
    wrote on last edited by
    #1

    I'm trying to set up a custom toolchain for compiling Qt 6.2 in Qt Creator, with a custom build of LLVM / clang and a custom sysroot. However, I can't figure out how to do it.

    The first thing I did was the obvious thing: I set up my compiler in Qt Creator's Kits preferences, and then created a new kit that uses my custom compiler and has a custom value for its sysroot field. That didn't work at all. Both the compiler and the sysroot value are completely ignored!

    The next thing I tried to do is create my own mkspec. I did so by first copying the macx-clang mkspec, adjusting the paths to its calls to include, and then explicitly set the values of QMAKE_CC and QMAKE_CXX, which did finally have an effect: now it's using my compiler.

    But I can't figure out how to change the value for isysroot that gets passed to the compilers. There's no obvious variable anywhere in any of the various mkspec files that defines it.

    The only thing I was able to find at all after greping through the whole Qt 6.2 mkspec directory is this bit in mkspecs/features/mac/default_post.prf, starting at line 224:

    sysroot_path  = $$xcodeSDKInfo(Path, $$device.sdk)
    ...
    version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
    QMAKE_CFLAGS += -isysroot $$sysroot_path $$version_min_flag
    QMAKE_CXXFLAGS += -isysroot $$sysroot_path $$version_min_flag
    

    It looks like this always gets executed no matter the mac mkspec I use, meaning it will always add the wrong isysroot argument to all compiler calls!

    Surely there's some way I can change the value of isysroot? Can anyone help? I've been bashing my head against this for hours now. :-(

    1 Reply Last reply
    0
    • Guy GizmoG Offline
      Guy GizmoG Offline
      Guy Gizmo
      wrote on last edited by
      #2

      I figured it out! I guess if you bash your head against something long enough, sometimes you break through before your head cracks.

      Here is the qmake.conf file in my mkspec that works, with file paths replaced with generic paths for readability:

      include(/path/to/qt/6.2.3/macos/mkspecs/macx-clang/qmake.conf)
      
      QMAKE_CC                          = /path/to/llvm/usr/bin/clang
      QMAKE_CXX                         = /path/to/llvm/usr/bin/clang++
      QMAKE_LINK                        = /path/to/llvm/usr/bin/usr/bin/clang++
      
      QMAKE_MAC_SDK.macosx.Path         = /path/to/sysroot
      QMAKE_MAC_SDK.macosx.SDKVersion   = 12
      

      The last line setting the macOS SDK version may not be needed, but is useful if the compiler and sysroot support a newer macOS SDK than the current installed version of Xcode. I found that in order for compilation to work, I also needed to set the environment variable QT_MAC_SDK_NO_VERSION_CHECK=1.

      That all said, this would have been A LOT easier and saved me hours of tough debugging if the kit settings for compiler and sysroot in Qt Creator actually did anything! I'll probably file a bug report.

      1 Reply Last reply
      0

      • Login

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