[CMake] Cross-platform build under Windows targeting Linux

Richard Shaw hobbes1069 at gmail.com
Mon Jun 10 16:06:01 EDT 2013


On Mon, Jun 10, 2013 at 2:06 PM, Matthew Woehlke <
matthew.woehlke at kitware.com> wrote:

> On 2013-06-10 04:52, setareh S wrote:
>
>> Now, I want to build my code for Linux platform(GNU/Linux) on a Win32
>> platform. I tried doing the above procedure using CMake combined with
>> Cygwin and using gcc and g++ as compilers. It built fine, created
>> makefiles, and when I issued "make" in Cygwin terminal, the generated
>> makefiles were "made". Now I have got an executable which I was hoping
>> would run on Linux platform. But on Linux I get the error: bash cannot
>> execute binary file.
>>
>> Using command file executablename, I realized the executable which is made
>> by the above procedure is of type PE32 which is only for Windows.
>>
>
> Are the compilers you are using cross-compilers, or the ones that came
> with cygwin? The normal cygwin gcc/g++ compilers target cygwin on win32 and
> are not cross-compilers.
>

DISCLAIMER: I'm not that familiar with cross-compiling BUT...

I think in general cross compiling from windows to linux is a bad idea.
Most distro's prefer to use the system installed libraries to build with
and link to, which you will not be able to do which pretty much leaves a
100% static build.

If you really want to do it then take a look here:

http://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130610/aed06cdf/attachment.htm>


More information about the CMake mailing list