6

I'm developing a qt-based application and i would like to develop both 32 and 64bit version of the application on the same machine, sharing the same sources, scripts, etc.. The machine is an Ubuntu Jaunty 64bit, Intel Core i7, 8gb ram. I'm aware that by running VMWare or VirtualBox could get things working, however it doesn't seem to be a good solution since i want to use the processor (i7) at its fullness. I read about a chrooted environment and it seems to me it could be the setup i was looking for: i need the development machine also to be able to run the executables just built.

Have you any experience on that? Did you setup such a 32bit chrooted env on a 64bit host? Does it work well? How to correctly setup it?

Manuel
  • 3,419
  • 1
  • 24
  • 22

2 Answers2

5

I've been in a similar, but not exact, situation. I was developing Qt4 applications for 32 bit Windows while running on 64 bit Jaunty. A chroot'd environment will give you what you want, with the minor annoyance of having to chroot over to it to compile your 32 bit application.

What I did to compile for Windows was to set up a cross compiler specifically for that purpose. You probably won't have to do that. You can probably get away with g++ -m32 compiling to 32 bits. To avoid having to edit makefiles and such a zillion times, you can create/modify/use the specfiles that come with Qt, such that you can do "qmake -project && qmake -makefile spec blablabla" (If I remember the syntax of the command properly).

ZachS
  • 1,238
  • 7
  • 11
  • I found out that "/mkspecs/" contains both linux-g++-32 and linux-g++-64 and these adds specifically -m32 and -m64. However i'm not pratical of chrooting so i'm searching for a guide or something on how to do that and to clear some obscure points i have on it, ie, do i need to start another Xserver for running the chrooted 32bit app? – Manuel Oct 02 '09 at 12:29
  • If you use the mkspecs, you shouldn't need to use a chroot. You will have to have both the 32-bit and 64-bit libs installed on your machine, but after that, you can run "qmake -project && qmake -makefile linux-g++- && make." It should then build on whatever bitness you want. – ZachS Oct 02 '09 at 13:35
  • Sure you are right ZachS, i justconfused things a bit: i'm going to try mkspecs first. – Manuel Oct 02 '09 at 14:56
3

I'm also in a similar situation, and here's how I work:

I use a custom built version of Qt. I build Qt twice, with the same configure options, except for the -platform parameter, which I set to linux-g++-64 for the first build and linux-g++-32 for the second build. I also use a different -prefix to install both versions in separate directories.

I use QtCreator to build my apps. I have added both Qt versions in the Options --> Qt4 --> Qt versions dialog. I then set up two different build configurations for my projects, with the same build options, but with one using the 32 bits Qt dir, and one using the 64 bits Qt dir. QtCreator then takes care of all the magic, and I simply need to alternate between the build configurations to have both a 32-bits and a 64-bits Qt app. No chroot, no VM, no nothing, just a simple build.

There is one caveat though. Building Qt for 32-bits obviously requires 32-bits versions of most development libraries (X libs, stdlibs, etc.), which are easily obtainable on Ubuntu Jaunty with ia32-libs and lib32stdc++6. The only libs I haven't managed to find for 32-bits development on 64-bits architecture are the gstreamer libs, meaning that Phonon might not work. I needed Phonon, so I worked aroud that by building Qt in a VM, then copying the Qt's installed directory back on my dev machine.

Good luck.

Fred
  • 4,894
  • 1
  • 31
  • 48
  • thanks, was looking for this. I will try your suggested VM method – CybeX Jan 24 '18 at 13:19
  • I need to query your solution. I am building Qt5.5.1 in a Ubuntu 16.04 (i386 / 32bit) VM. Beside the usual `./configure -prefix /path/to/Qt5-5-1/install/` and accept licence flags, did you specify any specific platform or related flags? I am using `./configure -opensource -nomake examples -nomake tests -confirm-license -prefix /opt/qt-5.5.1` Does this seem familiar, am I missing any flag? – CybeX Jan 24 '18 at 16:54