<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
<br>
<br>
Date: Mon, 10 Jun 2013 15:06:57 -0400<br>
From: Matthew Woehlke <<a href="mailto:matthew.woehlke@kitware.com">matthew.woehlke@kitware.com</a>><br>
Subject: Re: [CMake] Cross-platform build under Windows targeting<br>
Linux<br>
To: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
Message-ID: <kp584b$kl8$<a href="mailto:1@ger.gmane.org">1@ger.gmane.org</a>><br>
Content-Type: text/plain; charset=UTF-8; format=flowed<br>
<br>
On 2013-06-10 04:52, setareh S wrote:<br>
> Now, I want to build my code for Linux platform(GNU/Linux) on a Win32<br>
> platform. I tried doing the above procedure using CMake combined with<br>
> Cygwin and using gcc and g++ as compilers. It built fine, created<br>
> makefiles, and when I issued "make" in Cygwin terminal, the generated<br>
> makefiles were "made". Now I have got an executable which I was hoping<br>
> would run on Linux platform. But on Linux I get the error: bash cannot<br>
> execute binary file.<br>
><br>
> Using command file executablename, I realized the executable which is made<br>
> by the above procedure is of type PE32 which is only for Windows.<br>
<br>
>Are the compilers you are using cross-compilers, or the ones that came<br>
>with cygwin? The normal cygwin gcc/g++ compilers target cygwin on win32<br>
>and are not cross-compilers.<br>
<br>
Many thanks Matthew, yes you are right, I am using the compilers coming with Cygwin.</blockquote><div>What Cross compilers would you suggest to use on Win targeting Linux and vice versa? </div><div> </div><div>Best,</div>
<div> Setareh</div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"> <br><br>
<br>
------------------------------<br>
<br>
Date: Mon, 10 Jun 2013 15:06:01 -0500<br>
From: Richard Shaw <<a href="mailto:hobbes1069@gmail.com">hobbes1069@gmail.com</a>><br>
Subject: Re: [CMake] Cross-platform build under Windows targeting<br>
Linux<br>
Cc: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
Message-ID:<br>
<CAN3TeO0h-b_14yv0y7bc0-o4puS0CTRrkx8ZrFcKKX=<a href="mailto:6evSrtg@mail.gmail.com">6evSrtg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
On Mon, Jun 10, 2013 at 2:06 PM, Matthew Woehlke <<br>
<a href="mailto:matthew.woehlke@kitware.com">matthew.woehlke@kitware.com</a>> wrote:<br>
<br>
> On 2013-06-10 04:52, setareh S wrote:<br>
><br>
>> Now, I want to build my code for Linux platform(GNU/Linux) on a Win32<br>
>> platform. I tried doing the above procedure using CMake combined with<br>
>> Cygwin and using gcc and g++ as compilers. It built fine, created<br>
>> makefiles, and when I issued "make" in Cygwin terminal, the generated<br>
>> makefiles were "made". Now I have got an executable which I was hoping<br>
>> would run on Linux platform. But on Linux I get the error: bash cannot<br>
>> execute binary file.<br>
>><br>
>> Using command file executablename, I realized the executable which is made<br>
>> by the above procedure is of type PE32 which is only for Windows.<br>
>><br>
><br>
> Are the compilers you are using cross-compilers, or the ones that came<br>
> with cygwin? The normal cygwin gcc/g++ compilers target cygwin on win32 and<br>
> are not cross-compilers.<br>
><br>
<br>
DISCLAIMER: I'm not that familiar with cross-compiling BUT...<br>
<br>
I think in general cross compiling from windows to linux is a bad idea.<br>
Most distro's prefer to use the system installed libraries to build with<br>
and link to, which you will not be able to do which pretty much leaves a<br>
100% static build.<br>
<br>
If you really want to do it then take a look here:<br>
<br>
<a href="http://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux" target="_blank">http://stackoverflow.com/questions/4769968/c-cross-compiler-from-windows-to-linux</a><br>
Richard<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://www.cmake.org/pipermail/cmake/attachments/20130610/aed06cdf/attachment-0001.htm" target="_blank">http://www.cmake.org/pipermail/cmake/attachments/20130610/aed06cdf/attachment-0001.htm</a>><br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Mon, 10 Jun 2013 16:53:39 -0400<br>
From: Bill Hoffman <<a href="mailto:bill.hoffman@kitware.com">bill.hoffman@kitware.com</a>><br>
Subject: Re: [CMake] Cross-platform build under Windows targeting<br>
Linux<br>
To: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
Message-ID: <<a href="mailto:51B63CD3.5050105@kitware.com">51B63CD3.5050105@kitware.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
On 6/10/2013 4:06 PM, Richard Shaw wrote:<br>
><br>
> DISCLAIMER: I'm not that familiar with cross-compiling BUT...<br>
><br>
> I think in general cross compiling from windows to linux is a bad idea.<br>
<br>
I would agree. Much easier/faster to create a vm on windows. In fact<br>
my linux VM running on my windows box is able to compile much faster<br>
than the native windows compiler can on the same HW.<br>
<br>
-Bill<br></blockquote><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
Bill & Richard,</blockquote><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Thanks for your views on this. I will give the idea of cross compiling up if I see it is too hard to get it work or if it turns to be not that reliable. </blockquote>
<div>@Bill, I have never used vm, but my goal is to build my software for different platforms (to evaluate its performance and test it in the first place) and then be able to distribute the software for different platforms as well?I might be thinking in the wrong direction as I am new to software development field...Please feel free to correct me if I am missing something.</div>
<div> </div><div>@Richard,</div><div>Yes, you have got a totally valid point there, thanks for pointing that out to me. This way I would just have a 100% static build...which is perhaps not the most sophisticated approach to developing and distributing a software...</div>
<div> </div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">But then a question arises for me: If this procedure of cross-compiling is so involved, then the "CMake, cross-platform make" 's strongest functionality plus point, would be rather using more or less the same input file (CMakeLists.txt) with different generators on different native platforms to get the software built on the same platform, right?<br>
</blockquote><div>Best,</div><div>Setareh </div></div><br></div></div>