I am working on a C, project which uses ffmpeg
library. Currently I'm working on windows platform, and I'll be cross compiling the project for Linux ARM. With that background, I have few basic questions.
我正在做一个使用ffmpeg库的C项目。目前我正在使用windows平台,我将交叉编译Linux ARM项目。在这样的背景下,我有几个基本的问题。
-
If I use ANSI C++, I can be sure that, I'll be able to cross compile the project using corresponding compilers
[ MSVC, MingW ]
如果我使用ANSI c++,我可以肯定,我将能够使用相应的编译器来交叉编译项目[MSVC, MingW]
But ..
但. .
-
If I'm using "Win32" and other "Windows" specific APIs in my project, how does the cross compiler will handle it, to make the project able to run on Linux.
如果我在我的项目中使用“Win32”和其他“Windows”特定的api,那么交叉编译器将如何处理它,使项目能够在Linux上运行。
- Similarly, If I'm using Linux specific "features" in my project, how does the cross compiler will handle it, to make the project able to run on Windows.
- 类似地,如果我在我的项目中使用Linux特定的“特性”,交叉编译器将如何处理它,以使项目能够在Windows上运行。
2 个解决方案
#1
2
When you cross-compile, the code that is being cross-compiled must use APIs that are available on the target platform (ie, the one that it will eventually run on). A cross-compiler does not magically give access to Win32 APIs when its output is run on a Linux machine; it is the same as compiling the code on the target machine, but means you don't need to actually do so. You could achieve the same thing, in other words, by just running a native (non-cross) compiler on an ARM Linux box, but you'd need a powerful enough ARM box to run the compiler.
当交叉编译时,交叉编译的代码必须使用目标平台上可用的api(即最终运行的api)。当Win32 api的输出在Linux机器上运行时,交叉编译器不会神奇地提供对它的访问;这与在目标机器上编译代码是一样的,但是这意味着您实际上不需要这么做。换句话说,您可以通过在ARM Linux机器上运行一个本机(非交叉)编译器来实现同样的目的,但是您需要一个足够强大的ARM机器来运行编译器。
That said, in principle, you could cross-compile to Linux while using winelib to provide win32 APIs. Not sure how well it works on ARM though - it's only really meant to be used on x86.
也就是说,原则上,您可以在使用winelib提供win32 api的同时对Linux进行交叉编译。但不确定它在ARM上的效果如何——它只在x86上使用。
Finally, note that cross-compiling tends to be quite complex even in the best of times. It may make your life simpler to cross-compile from x86 Linux to ARM Linux instead of x86 Windows to ARM Linux - while it's possible to do cross-OS and cross-platform builds, the less variables you have changing the simpler things will be.
最后,请注意,即使在最好的情况下,交叉编译也是相当复杂的。从x86 Linux到ARM Linux,而不是x86 Windows到ARM Linux,交叉编译可能会让你的生活变得更简单——虽然可以进行跨操作系统和跨平台构建,但是改变的变量越少,事情就越简单。
#2
1
If you use Winapi, your project will not be able to run on Linux.
如果您使用Winapi,您的项目将无法在Linux上运行。
#1
2
When you cross-compile, the code that is being cross-compiled must use APIs that are available on the target platform (ie, the one that it will eventually run on). A cross-compiler does not magically give access to Win32 APIs when its output is run on a Linux machine; it is the same as compiling the code on the target machine, but means you don't need to actually do so. You could achieve the same thing, in other words, by just running a native (non-cross) compiler on an ARM Linux box, but you'd need a powerful enough ARM box to run the compiler.
当交叉编译时,交叉编译的代码必须使用目标平台上可用的api(即最终运行的api)。当Win32 api的输出在Linux机器上运行时,交叉编译器不会神奇地提供对它的访问;这与在目标机器上编译代码是一样的,但是这意味着您实际上不需要这么做。换句话说,您可以通过在ARM Linux机器上运行一个本机(非交叉)编译器来实现同样的目的,但是您需要一个足够强大的ARM机器来运行编译器。
That said, in principle, you could cross-compile to Linux while using winelib to provide win32 APIs. Not sure how well it works on ARM though - it's only really meant to be used on x86.
也就是说,原则上,您可以在使用winelib提供win32 api的同时对Linux进行交叉编译。但不确定它在ARM上的效果如何——它只在x86上使用。
Finally, note that cross-compiling tends to be quite complex even in the best of times. It may make your life simpler to cross-compile from x86 Linux to ARM Linux instead of x86 Windows to ARM Linux - while it's possible to do cross-OS and cross-platform builds, the less variables you have changing the simpler things will be.
最后,请注意,即使在最好的情况下,交叉编译也是相当复杂的。从x86 Linux到ARM Linux,而不是x86 Windows到ARM Linux,交叉编译可能会让你的生活变得更简单——虽然可以进行跨操作系统和跨平台构建,但是改变的变量越少,事情就越简单。
#2
1
If you use Winapi, your project will not be able to run on Linux.
如果您使用Winapi,您的项目将无法在Linux上运行。