LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-24-2013, 11:31 AM   #1
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 376

Rep: Reputation: 40
Working on Linux to compile for Windows


There was a time when I used to create quick c/c++ programs for Windows on my Linux computer. I used to compile them under Linux and copy the exe program to Windows and run and use it there.

I don't remember the command parameter. I have been searching the internet recently to find the compile option, but can't find it. Does anyone recall what it might be?

It was similar to:

Code:
#include <stdio.h>

int main()
{
	printf ("Hello World!\n");
	return 0;
}
For the Linux version:
Code:
gcc helloworld.cpp -o hello
And to compile a version for Windows:
Code:
gcc [special options] helloworld.cpp [special options] -o helloworld.exe
Thanks in advance for any suggestions or comments.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
Old 07-24-2013, 01:21 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,635
Blog Entries: 13

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
First thought was, "never heard of such an oddity", but it exists, google string was "compile in linux for windows" and it yielded a few hits that look plausible.

http://www.blogcompiler.com/2010/07/...dows-on-linux/
http://stackoverflow.com/questions/2...nux-with-gcc-g

Well, both talk about using mingw, and they're a few years old. Have you tried this or something similar?
 
Old 07-24-2013, 08:19 PM   #3
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 376

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by rtmistler View Post
First thought was, "never heard of such an oddity", but it exists, google string was "compile in linux for windows" and it yielded a few hits that look plausible.

http://www.blogcompiler.com/2010/07/...dows-on-linux/
http://stackoverflow.com/questions/2...nux-with-gcc-g

Well, both talk about using mingw, and they're a few years old. Have you tried this or something similar?
Rtmistler, thanks! Your link works. I had read many links that was discussing mingw32 and it's installation, but somehow missed the gist. I thought I had recalled running gcc with some parameter to call the windows libraries and linkers. But it might have actually been the mingw32-gcc command that I had been using.

Anyway I'm able to compile my windows programs on linux with:

Code:
$ x86_64-w64-mingw32-gcc hello.cpp -o hello.exe
There are a few simple applications I'll have to make for my Windows customers that can't be handled by bash files. It saves me a lot of time by not having to go to a Windows machine to do the developing.

I had just dug out my old Visual Studio and got ready to install it on a Windows machine, which was going to be tedious.

My the way, lots of messages on the Internet are saying it's not possible to compile Windows programs on a Linux machine. So I'm sure this thread should get a bunch of hits, resolving this issue for other searchers.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to cross compile linux on windows 7 ? iamlinux Linux - General 1 02-13-2013 01:55 PM
How to compile qt linux prog for windows? zackarya Programming 1 08-08-2006 01:58 AM
Compile linux source for windows? jaykup Programming 5 03-10-2006 12:56 PM
running in windows from linux compile fisheromen1031 Programming 2 07-21-2004 01:01 PM
Compile linux program for windows Mor_Petrus Programming 3 04-08-2003 11:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration