LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-02-2013, 12:35 PM   #1
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Rep: Reputation: 30
C program doesn't compile on Windows


My C program compiles on Ubuntu Linux 13.04 and gcc but, the same program, doesn't compile on Windows Seven and Dev-C++.

The error is:
[Linker error] undefined reference to 'WinMain@16'
ld returned exit status


What's the problem?
 
Old 07-02-2013, 12:53 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
It looks like it does compile, but that the entry point for a Windows 7 program isn't main like it is in C.

Kevin Barry
 
Old 07-02-2013, 01:33 PM   #3
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
It seems that I must define a project in Dev-C++, and within that I must insert my files.
 
Old 07-02-2013, 03:19 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You have to tell the compiler generate a "console" application instead of a "windows" one. In terms of gcc, that means remove the -mwindows flag (or add the default -mconsole flag, see 3.17.17: i386 and x86-64 Windows Options). I'm not sure where the setting shows up in Dev-C++.
 
Old 07-04-2013, 01:40 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Your function 'main' isn't standard. Try this:
Code:
int main (int, char *argv[]) {...}
 
  


Reply



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
Kdevelop doesn't compile my c++ program emab Programming 5 08-18-2008 08:07 PM
why doesn't my fortran program compile?? himan Programming 1 04-11-2004 10:43 PM
Is it possible to compile a windows .exe program using g++? fuzzyworm Programming 5 02-05-2004 04:55 PM
Compile linux program for windows Mor_Petrus Programming 3 04-08-2003 11:11 AM
Why doesn't this simple program compile? SparceMatrix Programming 4 08-27-2002 03:37 AM

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

All times are GMT -5. The time now is 07:01 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
Open Source Consulting | Domain Registration