[CMake] Cross-platform build under Windows targeting Linux

setareh S setareh.s1984 at gmail.com
Tue Jun 11 09:57:52 EDT 2013


>
>
>
> Date: Mon, 10 Jun 2013 15:06:57 -0400
> From: Matthew Woehlke <matthew.woehlke at kitware.com>
> Subject: Re: [CMake] Cross-platform build under Windows targeting
>         Linux
> To: cmake at cmake.org
> Message-ID: <kp584b$kl8$1 at ger.gmane.org>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> 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.
>
> Many thanks Matthew, yes you are right, I am using the compilers
> coming with Cygwin.

What Cross compilers would  you suggest to use on Win targeting Linux and
vice versa?

Best,
 Setareh

>
>
>
> ------------------------------
>
> Date: Mon, 10 Jun 2013 15:06:01 -0500
> From: Richard Shaw <hobbes1069 at gmail.com>
> Subject: Re: [CMake] Cross-platform build under Windows targeting
>         Linux
> Cc: cmake at cmake.org
> Message-ID:
>         <CAN3TeO0h-b_14yv0y7bc0-o4puS0CTRrkx8ZrFcKKX=
> 6evSrtg at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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-0001.htm
> >
>
> ------------------------------
>
> Message: 6
> Date: Mon, 10 Jun 2013 16:53:39 -0400
> From: Bill Hoffman <bill.hoffman at kitware.com>
> Subject: Re: [CMake] Cross-platform build under Windows targeting
>         Linux
> To: cmake at cmake.org
> Message-ID: <51B63CD3.5050105 at kitware.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 6/10/2013 4:06 PM, Richard Shaw wrote:
> >
> > DISCLAIMER: I'm not that familiar with cross-compiling BUT...
> >
> > I think in general cross compiling from windows to linux is a bad idea.
>
> I would agree.  Much easier/faster to create a vm on windows.  In fact
> my linux VM running on my windows box is able to compile much faster
> than the native windows compiler can on the same HW.
>
> -Bill
>


> Bill & Richard,



> 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.

@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.

@Richard,
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...



> 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?
>
Best,
Setareh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130611/fdc80d42/attachment-0001.htm>


More information about the CMake mailing list