Compiling for linux

I'm running windows and i would like to compile for Linux is there a way to compile on windows or do i have to compile on Linux. If so can you help me setup a VM.

Edit: Code is cross platform.
Last edited on
closed account (Dy7SLyTq)
there are a couple of options
a) write code you know is portable on windows so that someone can compile on linux
b) use a virtual linux machine
c) make a cross compiler for linux
The code is cross platform. And im asking about cross compiler and VMs.
If you want a cross-compiler, you can download the source for one, but IMO the best thing would be to do a VM.

Here's a good, free, open-source program to run your virtual machine:
https://www.virtualbox.org/wiki/Downloads

And go get your choice of linux. Since this is a VM, you'll probably want something more lightweight than if you were using as a native install. One distro I personally user for development is #! (http://crunchbang.org). I believe it even has a compiler installed already (if not, you can use open a terminal and run apt-get update && apt-get install build-essential to get a few developer essentials including g++ and the "make" program).
Last edited on
If his code is at all demanding to compile, it won't go well in a virtual machine.

Setting up a cross-compiler is what I'd recommend, as it was an awesome experience for me (setting up for Linux-to-Win compilation) that taught me a lot. I'd definitely recommend you go and set up a cross-compiling environment. Your compilation times will also be shorter if you do this.
Setting up a cross compiler can be pretty challenging. It's just about impossible to build anything on Windows - I have had more success making the cross compiler in a Linux VM.

0. Ensure you have an OnLinux-FromLinux-ToLinux
1. Make an OnLinux-FromLinux-ToWindows cross compiler
2. Using the above compiler, make an OnLinux-FromWindows-ToWhatever cross compiler (in your case, Whatever is Linux)
3. Install the compiler from step 2 on your windows machine

Once you get step 1 done, step 2 is easy. Note that my OnBlah-FromBlah-ToBlah syntax is parallel to --build, --host, and --target for gcc's configure script.
Last edited on
closed account (Dy7SLyTq)
If his code is at all demanding to compile, it won't go well in a virtual machine.

what are you talking about? i develop on a windows vm just fine. the only issue i have with vms is the resource sharing. other than that unless there is a bug in virtual box then it works fine (if theres one with windows then it wont matter if its virtual or host. on the other hand, boot strapping a cross compiler is going to be more prone to bugs and full of drawbacks like lack of certain libraries (unless you are able to recompile them on linux which would be a pain)
Topic archived. No new replies allowed.