GNU gcc 和 g++

发布于 2024-12-21 23:06:00 字数 231 浏览 5 评论 0原文

MAC OS X 计算机上安装的 gcc 和 g++ 编译器与 Ubuntu (Linux) GNU gcc 和 g++ 编译器上安装的不同吗?

我正在使用 Eclipse 开发 C++ 程序,工具链部分显示 MacOSX GCC,我想知道是否需要安装另一个编译器,以便可执行文件也可以在 Linux 计算机上运行。

我对 C++ 开发的技术细节有点陌生,所以如果这个问题没有意义,我很抱歉。

Are the gcc and g++ compilers installed on a MAC OS X machine different from the ones on Ubuntu (Linux) GNU gcc and g++ compilers?

I am using Eclipse to develop a C++ program and there is toolchain section where it says MacOSX GCC and I was wondering if I need to install another compiler so that the executable would also run on Linux machines.

I am a bit new to the technical details of C++ development so I am sorry if this question does not make sense.

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

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

发布评论

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

评论(2

酒绊 2024-12-28 23:06:00

二进制文件不太可能同时在 Mac 和 Linux 上执行。二进制文件很可能无法在不同的 Linux 发行版之间执行。您可以为每个操作系统编译二进制文件。或者,您可以分发应用程序的源代码并让用户自行编译。

不同版本的 libstdc++.so 可能随不同操作系统一起分发,这会给您带来问题。部分有效的解决方案是静态编译二进制文件,这样您就不会依赖于目标系统安装的库版本。

It it very unlikely that binary will execute on both Mac and on Linux. If is pretty likely that a binary will not execute between different distro's of Linux. You can either compile you binary for each OS. Or you can distribute the source code for you application and let you users compile it themselves.

Different versions of libstdc++.so are likely distributed with different OS's and this will cause you problems. A solution that partly works is to statically compile your binary so you are not depending on the target systems installed version of libraries.

我一向站在原地 2024-12-28 23:06:00

MacOS 不是 Linux,它可能与 BSD 有一些共同点,但绝对不是 Linux。他们确实或可以使用同一编译器的不同配置,但程序不兼容。

在两者上运行相同程序的唯一方法是如果您有像 Wine 这样的东西来提供兼容层。

MacOS is not Linux, it might have a bit in common with BSD, but definitely not Linux. They do, or can, use different configurations of the same compiler, but the programs are not compatible.

The only way you're going to run the same program on both is if you have something like Wine to provide a compatibility layer.

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