用于 32 位*和*64 位 Qt 应用程序开发的最佳 Ubuntu 设置?

发布于 2024-08-06 15:58:19 字数 325 浏览 3 评论 0原文

我正在开发一个基于 qt 的应用程序,我想在同一台计算机上开发该应用程序的 32 位和 64 位版本,共享相同的源、脚本等。 该机器是 Ubuntu Jaunty 64 位、Intel Core i7、8GB 内存。 我知道通过运行 VMWare 或 VirtualBox 可以使事情正常运行,但这似乎不是一个好的解决方案,因为我想充分利用处理器(i7)。 我读到了有关 chrooted 环境的信息,在我看来,这可能是我正在寻找的设置:我需要开发计算机也能够运行刚刚构建的可执行文件。

你有这方面的经验吗?您是否在 64 位主机上设置了这样的 32 位 chroot 环境?效果好吗?如何正确设置呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筱果果 2024-08-13 15:58:20

我也处于类似的情况,这就是我的工作方式:

我使用 Qt 的定制版本。我使用相同的配置选项构建了 Qt 两次,除了 -platform 参数,第一次构建时我将其设置为 linux-g++-64linux -g++-32 用于第二次构建。我还使用不同的 -前缀 将两个版本安装在单独的目录中。

我使用 QtCreator 来构建我的应用程序。我已经在选项中添加了两个 Qt 版本 --> Qt4 --> Qt 版本对话框。然后,我为我的项目设置了两种不同的构建配置,具有相同的构建选项,但一种使用 32 位 Qt 目录,另一种使用 64 位 Qt 目录。然后,QtCreator 会处理所有的问题,我只需要在构建配置之间进行切换即可同时拥有 32 位和 64 位 Qt 应用程序。没有 chroot,没有虚拟机,什么都没有,只是一个简单的构建。

但有一点需要注意。构建 32 位 Qt 显然需要大多数开发库(X libs、stdlibs 等)的 32 位版本,这些库可以在 Ubuntu Jaunty 上通过 ia32-libs 和 lib32stdc++6 轻松获得。我唯一没有找到在 64 位架构上进行 32 位开发的库是 gstreamer 库,这意味着 Phonon 可能无法工作。我需要 Phonon,因此我通过在 VM 中构建 Qt,然后将 Qt 的安装目录复制回我的开发计算机来解决这个问题。

祝你好运。

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.

北恋 2024-08-13 15:58:19

我也遇到过类似的情况,但不完全一样。我正在为 32 位 Windows 开发 Qt4 应用程序,同时在 64 位 Jaunty 上运行。 chroot 环境将为您提供所需的内容,但有一个小麻烦,即必须 chroot 到它才能编译 32 位应用程序。

我为 Windows 进行编译的方法是专门为此目的设置一个交叉编译器。你可能不必这样做。您可能可以通过 g++ -m32 编译为 32 位来摆脱困境。为了避免编辑 makefile 和如此无数次,您可以创建/修改/使用 Qt 附带的规范文件,这样您就可以执行“qmake -project && qmake -makefile spec blablabla”(如果我记得命令语法正确)。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文