views:

1252

answers:

3

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?

+3  A: 

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
I found out that "<qtdir>/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
ZachS
Sure you are right ZachS, i justconfused things a bit: i'm going to try mkspecs first.
Manuel
+1  A: 

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
A: 

Hi! Does anyone know how to create a complete Qt-build-env for 32 on 64? With -platform linux-g++-32, the libs are 32bit, but the dev tools (qmake, moc, etc) are still 64 bits. That's okay for "cross compiling", but not okay if you want to distribute the build env to others ...

Well, in any case, using a vm should work - it's just that I have a few more cores on the host than on the vm ...

Thank, Sebastian