programming for windows from linux

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

programming for windows from linux

Post by sevc on Mon Jun 23, 2008 9:58 am
([msg=5566]see programming for windows from linux[/msg])

I'm using a linux computer at home, but I want to be able to write programs that my friends (all of which use windows) will be able to use. So far, my solution has been java. However, the majority of my friends are not tech-savvy enough to run a java program from the terminal. Is there a way to write C or C++ programs on my linux computer, but compile them for windows?

If my question is stupid, please don't get mad at me, I'm a N00B, and I'm also barely 14.
sevc
New User
New User
 
Posts: 1
Joined: Thu May 22, 2008 3:13 pm
Blog: View Blog (0)


Re: programming for windows from linux

Post by BhaaL on Mon Jun 23, 2008 11:22 am
([msg=5569]see Re: programming for windows from linux[/msg])

There is a way to cross-compile applications written in C/C++, but that requires you to install a compiler for the target platform.
In your case, you'd have to install a gcc/g++ version that compiles to win32 PE, but is an *nix ELF itself.
I never tried this myself, so you'll probably have to poke around your package manager and/or the GCC homepage for those.

Just keep in mind you have to write portable code for that, which isnt that much of a deal for linux -> win32, but vice-versa always keep people busy when they first try that ;)
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)


Re: programming for windows from linux

Post by comperr on Wed Jun 25, 2008 9:50 pm
([msg=5778]see Re: programming for windows from linux[/msg])

also remember that testing is a pain if you don't have windows
User avatar
comperr
Poster
Poster
 
Posts: 373
Joined: Mon Apr 07, 2008 6:52 pm
Location: /dev/null
Blog: View Blog (0)


Re: programming for windows from linux

Post by Soul13 on Wed Jun 25, 2008 11:05 pm
([msg=5783]see Re: programming for windows from linux[/msg])

If you put the java program in a jar you can double click and run that if you set up the manifest, imo it would be easier than cross-compiling.
Soul13
New User
New User
 
Posts: 1
Joined: Mon Jun 23, 2008 9:16 pm
Blog: View Blog (0)


Re: programming for windows from linux

Post by OneArrow on Thu Jun 26, 2008 10:28 am
([msg=5821]see Re: programming for windows from linux[/msg])

Soul13 wrote:If you put the java program in a jar you can double click and run that if you set up the manifest, imo it would be easier than cross-compiling.


Alanna wrote:Saying that Java is nice because it works on all OSs is like saying that anal sex is nice because it works on all genders.
OneArrow
Poster
Poster
 
Posts: 123
Joined: Thu May 22, 2008 8:26 pm
Blog: View Blog (0)


Re: programming for windows from linux

Post by nyt3 on Tue Jul 15, 2008 1:05 am
([msg=7440]see Re: programming for windows from linux[/msg])

I'd avoid Java as much as possible for serious programs. If you want lean, mean, speedy programs - stick with c/c++. Java does run on nearly all operating systems, but it is an interpreted language - this means the code you write is turned into java machine code which is then interpreted by the java virtual machine which you must install to run Java programs. a compiler on the other hand takes C/C++ and turns it right into machine language - eliminating the memory usage of an interpreter and shrinking the overall required file size of your program. (i'm an IST major (formerly computer science) and took classes in both c++ and java in college so i have a fair idea of what i'm talking about)

on top of that I quit windows and run purely Gentoo Linux on my desktop. You didn't say what distro you were using, so i can't give very specific instructions, but i can say that I compile windows executables and test them under linux. In Gentoo portage there is a program called crossdev - with this you can build compilers to make programs that run on different architectures and operating systems. for example - i installed a compiler i686-mingw32-gcc and can now create 32 bit windows .exe files. to test them I simply run them with wine - "wine myprogram.exe".

http://gentoo-wiki.com/HOWTO_Cross_Compile to learn to do this on gentoo.
http://www.mingw.org/ may also be helpful
nyt3
New User
New User
 
Posts: 1
Joined: Fri Jun 06, 2008 10:55 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron