跨平台构建库而不运行所有平台
我有一小段代码,可以用作较大图形应用程序的插件。 开发平台是Qt,带有c++代码。 我已经成功地分别为 linux、MacOS 和 Windows 构建了 .so、.dylib 和 .dll,但要做到这一点,我必须有一台运行每个操作系统的机器(在我的例子中,本地运行 linux [ubuntu] gcc,以及虚拟机中的 Windows MinGW 和 MacOS XCode gcc)。
有没有一种方法可以从一个平台构建所有 3 个平台? 不久前,我对这个问题绞尽脑汁,迄今为止的研究表明,这并不容易(或可行)完成。 代码只需要链接到定义插件的单个标头 API 是由一个相当基本的 Makefile 构建的(目前每个平台都有很小的变化)。
I have a small piece of code that works as a plugin for a larger graphics application. The development platform is Qt with c++ code. I've managed to build a .so, .dylib and .dll for linux, MacOS and Windows respectively, but to do so I had to have a machine running each operating system (in my case, running linux [ubuntu] gcc natively, and windows MinGW and MacOS XCode gcc in virtual machines).
Is there a way to build for all 3 platforms from one? I beat my head against this problem a while back, and research to date suggests that it's not easily (or feasibly) done. The code only needs to link against a single header that defines the plugin
API and is built from a fairly basic Makefile (currently with small variations per platform).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你应该看看交叉编译。
您基本上构建了一个编译器(在您当前的平台上)将为您所需的平台输出二进制文件。
尝试此链接了解如何在 Linux、Windows 和 QT 上执行此操作
You should have a look at crosscompiling.
You basically build a compiler that (on your current plattform) will output binaries for your desired platforms.
Try this link about doing it on linux, for windows, with QT
迟到总比不到好,我刚刚遇到了 IMCROSS
它看起来很有前途!
Better late than never, I just came across IMCROSS
It looks quite promising!
对于 Linux,使用 VMWare 设置甚至下载虚拟机相当容易。 让 OSX 在 VMWare 上运行有点棘手,但也是可能的。
运行 VMWare 并在本地驱动器上共享目录,您甚至可以使用相同的文件为不同平台进行编译。
某个地方有一个 OSX 交叉编译器,但我不相信它的质量很高。
For Linux it is fairly easy to setup or even download a virtual machine using VMWare for instance. Getting OSX to run on VMWare is somewhat tricky but possible.
Running VMWare and sharing a directory on a local drive you can even compile for the different platforms using the same exact files.
There is somewhere a cross-compiler for OSX but I wouldn't trust it to be of great quality.