Visual C 可以吗?程序可以在 Mac OS X 或 Linux 上编译并运行吗?
……如果是这样,怎么办?
具体来说,我想编译并运行 wavdiff< /a> 在 Mac OS X Snow Leopard 10.6.8 上。据我所知(这并不是很远,因为我在 C++ 方面完全是新手),这是用 MS Visual C++ 或类似工具创建的。
我将非常感谢能够解决在 Mac OS X 或 Linux 上编译 Visual C++ 程序的一般情况以及解决上述特定挑战的答案。
… and if so, how?
Specifically, I'd like to compile and run wavdiff on Mac OS X Snow Leopard 10.6.8. As far as I can tell (which isn't very far, since I'm a total novice at C++), this was created with MS Visual C++ or similar.
I'd be most grateful for answers that address the general case of compiling Visual C++ programs on Mac OS X or Linux, and that also address the specific challenge above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
C++ 语言是可移植的。理论上,C++源代码可以编译运行在任何平台上。
但是,有一些注意事项需要注意:
long
在 64 位 Linux 上通常为 64 位宽,但在 64 位 Windows 上仅为 32 位。wchar_t
在 Windows 上为 16 位宽,但在 Linux 上通常为 32 位。因此,如果您的代码对实现定义的行为做出假设,则它可能不可移植(一个典型的示例是假设指针可以存储到int
或unsigned int
中的代码>. 这在 32 位机器上效果很好,但在 64 位机器上,所以这实际上取决于代码。干净、高质量的代码往往可以轻松移植。当然,直接依赖于操作系统服务的部分除外,这些部分必须针对不同的操作系统进行重写(或者可能有跨平台包装器/库,可以用于以可移植的方式执行相同的操作)
The C++ language is portable. In theory, C++ source code can be compiled to run on any platform.
However, there are a few caveats to be aware of:
long
is typically 64 bits wide on 64-bit Linux, but only 32-bit on 64-bit Windows. Awchar_t
is 16 bits wide on Windows, but typically 32 bits on Linux. So if your code makes assumptions about implementation-defined behavior, it might not be portable (a classic example is code which assumes that a pointer can be stored into anint
orunsigned int
. That works great on a 32-bit machine, but on 64-bit, you end up trying to store 64 bits of data into a 32 bit wide object.So it depends on the code, really. Clean, high-quality code tends to be portable with little trouble. Except of course for the parts that rely directly on OS services, which will have to be rewritten for a different OS (or where a cross-platform wrapper/library may be available which can be used to do the same thing in a portable manner)
该程序无法轻松移植(无需更改源代码即可重新编译)。至少在不更改源代码的情况下是这样。它具有对 Windows 库的依赖关系,并在某些部分与 Windows API 相关联。
问题不在于它是用 VC++ 编写的,而在于它具有这些依赖项。在很多情况下,只要在目标平台上重新编译或切换到不同的平台,就可以轻松移植不依赖平台的程序。
This program can not be easily ported (recompiled without source changes). At least not without changes to the source. It holds dependencies to Windows libraries and is tied to Windows API in certain parts.
The problem is not that it's coded in VC++, but that it has these dependencies. A program that is coded such that it has no platform-dependencies can be easily ported in a lot of cases by just recompiling on the target platform or with a switch to target a different platform.
仅基于此源文件,看起来代码本身可能是相当可移植的 C++。问题是它(或它使用的任何类)是否使用了其他平台上不存在的 Windows API。你可以做的赌注是询问作者的想法,或者只是尝试一下。
Based just on this source file, it looks as if the code itself might be reasonably portable C++. The question is whether it (or any of the classes it uses) makes use of Windows APIs that won't exist on those other platforms. The bet you can do is ask the authors what they think, or just give it a try.