交叉编译教程
可能的重复:
跨平台编程
我在c++中使用wxwidgets编写了一些代码。但我无法为 Windows 和 Linux 编译相同的代码。实际上,我对代码块 ide 生成的预处理器指令有点害怕。我想知道是否有人可以指出一些学习交叉编译的好教程。
提前致谢
Jvc
Possible Duplicate:
Cross platform programming
I've written some code using wxwidgets in c++. But I am not able to compile the same code for both windows and linux. Actually I'm a bit scared by the preprocessor directives generated by code-blocks ide. I wonder if anyone could point out some nice tutorials for learning cross-compilation.
Thanks in Advance
Jvc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想构建跨平台程序,您会遇到一些问题。
交叉编译器问题
某些编译器提供的非标准功能可能无法在其他编译器上运行。您必须确保您使用的编译器功能是标准的或在您使用的所有编译器上可用(例如 VC++
#pragma
直到版本 4.2.1 才在 gcc 上使用)< strong>特定于平台的函数和库
猜猜看,如果包含
它不会在 Linux 系统上编译(这是我知道这很疯狂)。所以你必须尽量避免那些特定于平台的库/函数。如果您必须使用它们,请尝试封装它们的使用并选择您需要在不同系统上编译的特定类。这是 Mozilla 基金会发布的精彩指南:
https://developer.mozilla.org/en/C___Portability_Guide
If you want to build a cross platform program, you will stumbl across a few kind of problems.
Cross compilers problem
Some compilers are offering non-standard functionalities that might not work on other compiler. You have to make sure that compiler functionnalitie's you use are standard or available on all the compilers you use (An exemple would be the VC++
#pragma
that wasn't usable on gcc until version 4.2.1)Platform specific functions and libraries
Guess what, if you include
<windows.h>
it won't compile on a linux system (this is madness I know). So you must try to avoid those platform specific libraries/function. If you ever have to use them, try to encapsulate their use and select the specific class you need to compile on different system.Here is a wonderful guide posted by the Mozilla foundation :
https://developer.mozilla.org/en/C___Portability_Guide
你可以看看在 Linux 上交叉编译 wxWidgets 应用程序(代码::Blocks wiki)和Linux 下的交叉编译 (wxWiki)。 Brent W. Woodruff WxWidgets 的 C++ 简介。
You could have a look at Cross Compiling wxWidgets Applications on Linux (Code::Blocks wiki) and Cross-Compiling Under Linux (wxWiki). There is also a section on cross compiling Windows applications in Brent W. Woodruff C++ Introduction to wxWidgets.