Qt Creator: build in a chroot environment



  • I am trying to setup Qt Creator so that I can build an application in a chroot environment.

    At the moment I am able to build the application from the command line using cmake, but I would prefer to be able to also build, run, and debug the application from Qt Creator.

    My current idea is to prepare wrapper scripts for the development environment (cmake, gdb, g++, qmake) that would just call the appropriate binary inside the chroot environment (I haven't tried it yet, so it might not even work).

    I also found the "sysroot" option in kit configuration which makes me think that it might not even be necessary to prepare wrapper scripts, but to just find the appropriate binaries in the file system and set the "sysroot" path.

    What would be the best way to configure Qt Creator to get this to work?

    P.S.: I am working with CentOS 4.2 chroot environment.



  • That use-case is not covered out of the box, sorry.

    Sysroot is intended to be used for cross-compilation, not for in-chroot compilation. So I do not think that is what you want.

    There are two hacky ways to build something in a chroot though:

    • I just installed my Qt Creator inside the chroot and use it from there. That is probably the easiest approach, but leads to way more libraries being installed in the chroot than strictly necessary. I mostly work on Qt Creator itself, so the dependencies of the Qt Creator I run as an IDE and the program I work on do match up fully anyway:-)

    • There were embedded projects that went down the wrapper-way. Basically they used wrapper scripts for cmake and some other things that forwarded calls into a VM/chroot/container and executed them there. The tricky part here is to make sure the sources (preferably including system headers!) are in the same place inside and outside the VM/chroot/container. Otherwise you will need to map paths back to the outside environment for Creator to actually jump to errors and such and the code model will also break:-)

    As for running in another environment: Creator supports SSH-ing into another machine and run/debug stuff there. With a bit of work it can even automatically copy the binaries into place and everything. So if you just need to run something in a fully defined environment of an VM/chroot/container, then that is easy if you can manage to run a SSH server there and to install gdbserver.


Log in to reply