Linux to Windows

This is a discussion on Linux to Windows within the Linux Programming forums, part of the Platform Specific Boards category; If i compile and make an executable on linux, is it possible for it to be executed on windows, ive ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515

    Linux to Windows

    If i compile and make an executable on linux, is it possible for it to be executed on windows, ive tried it, but i get an error that the file has encountered an illegal instruction. The file is just a simple hello world program including just one printf statement.
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,833
    You need to run a compiler which generates windows executables on your Linux box.
    Does dev-c++ work within WINE I wonder?

    What you're basically talking about is a cross-compiler, which runs on machine 'a', but produces executables for machine 'b'. Since in your case, 'b' is a windows machine with many compilers readily available, true linux-to-windows cross compilers are pretty rare.
    Mostly people just copy the source across and compile it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    Umm..but well, if i compile things using linux using say posix threads and sockets, i want to port it to windows..would that be possible ?? i ll try getting devcpp to work on wine.
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,833
    Well you still need to make sure that the code you compile for windows is valid windows source code (all the correct API calls for example), no matter where you compile it.

    It won't magically fix your posix threads and sockets into win32 API for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    Okay, i tried using devcpp on linux, it installs properly, but i dont seem to be able to run it..so, basically, i ll have to understand windows based multithreading and sockets if i want to make something that can work on windows?
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,833
    You have to write the code which you would write if you were sitting at a windows machine with dev-c++ installed.

    Like network programs begin and end with wsaStartup() and wsaCleanup()

    Installing dev-c++ via WINE on your linux box saves some walking about (perhaps), but you still need to get over to the windows box to test the executable.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    Yes, porting the network part would be ok i guess, not much of a difference, but the threading part would mean that id have to do windows based multithreading right? i remember adrian had written a tutorial on this..i ll try n search for it, thank you for the help
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  8. #8
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    269
    As Salem said, lack of libraries makes it difficult to port some applications to windows. MAybe you should search msdn for porting applications from unix to windows. I know there is such a section exists but not sure if it can satisfy you!

  9. #9
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    I know there is such a section exists but not sure if it can satisfy you
    You mean on msdn? can you give me a link to the one you are talking about? i ll search for it nonetheless..
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  10. #10
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Boost contains both threading and (in the upcoming 1.34 release, I think, but I'm not sure) networking libraries that work on both Windows and various Unix-likes.
    The networking library is called ASIO, you can also get it at asio.sourceforge.net.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    Okay, thankyou..will look into it
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  13. #13
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    pthreads is available on Windows. (I hope that's where I got my pthread's library from...)
    As for sockets, good luck. Depending on the code, it can be as simple as adding in the calls that Salem mentioned or much more complex. If you have any specific problems, that's what these boards are for.

    I sort of looked at asio and started to write my own sockets wrapper... but it's preference.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  14. #14
    Registered User
    Join Date
    Dec 2006
    Posts
    2
    I think what you want is mingw, I believe it has a cross compiler. For information on cross compiling, you can google 'mingw cross compile' as I did. I found one article, although it's supposedly for WxWindows (The article), it should still work for you: here. Hope that helps, sorry if that's not what you meant.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. windows .dll vs. linux .so - global static objects
    By pheres in forum C++ Programming
    Replies: 11
    Last Post: 11-23-2010, 01:29 PM
  2. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 12:40 PM
  3. Build linux on windows
    By baash05 in forum Linux Programming
    Replies: 6
    Last Post: 02-19-2008, 10:12 PM
  4. Why can't Windows run Linux binary executables?
    By Kleid-0 in forum Tech Board
    Replies: 30
    Last Post: 12-04-2005, 11:44 PM
  5. Linux and Windows Duel Boot
    By The15th in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-26-2002, 05:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21