Linker Error Undefined Reference To Winmain16
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company linker error undefined reference to winmain@16' dev c++ Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Undefined Reference To Winmain@16' Codeblocks
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, linker error undefined reference in c just like you, helping each other. Join them; it only takes a minute: Sign up Linker error undefined reference to `WinMain@16', ld returned 1 exit status up vote 0 down vote favorite 1 I'm having this error:
C++ Undefined Reference To Class
Linker error undefined reference toWinMain@16'` Here's the code: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I solve the following errors: “Undefined reference to WinMain”, “[Error] Id returned 1 http://stackoverflow.com/questions/21127146/linker-error-undefined-reference-to-winmain16-ld-returned-1-exit-status exit status”? [duplicate] up vote 0 down vote favorite This question already has an answer here: undefined reference to `WinMain@16' 4 answers I'm writing a C program and using Dev C++ to compile/run it. However, it's coming up with the error: undefined reference to 'WinMain'" and "[Error] Id returned 1 exit status" What do these errors mean, and how do I solve them? The WinMain error appears to be linked to http://stackoverflow.com/questions/26470353/how-do-i-solve-the-following-errors-undefined-reference-to-winmain-error line 18 of my code which is... int read_char() { return getchar(); } Any ideas? I'm a beginner with C, and I haven't found an answer to this question that I understand. I presume it's because I'm using Windows. Would the code work on linux as it is perhaps? c dev-c++ share|improve this question edited Oct 20 '14 at 16:32 David Heffernan 431k27585952 asked Oct 20 '14 at 16:23 Wolff 159213 marked as duplicate by Deduplicator, JasonMArcher, James Kingsbery, cpburnz, IdeaHat Oct 20 '14 at 18:24 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. I don't know "Dev C++" but shou should probably start a "Windows console" project or something like this. –Michael Walz Oct 20 '14 at 16:25 How are you going to use getchar() function in window? –Seprum Oct 20 '14 at 16:29 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote This error means that the linker is looking for a function named WinMain to use as the entry point. It would be doing that because you configured the project to target the GUI subsystem, but did not provide a WinMain fu
Thread Tools Search this Thread Rating: #1 23-Feb-2006, 19:36 vermin1302 Awaiting Email Confirmation Join Date: Feb 2006 Location: Indiana, USA Posts: 19 [Linker error] https://www.gidforums.com/t-8754.html undefined reference to `WinMain@16' I'm using Dev-C++ 4.9.9.2 to compile a program http://www.bloodshed.net/dev/faq.html I wrote about five years ago. I recall that it compiled without errors when I first wrote it. I had to change a few things, because I guess the code was getting a little old. Anyway, I got rid of all of the errors except this WinMain@16 thing. I've undefined reference noticed that this can be a problem if you're writing a console program and accidentally have your project set to Windows Program, but I've checked this and it's definitely set as a console program. So now I'm not exactly sure what to do. My code is attached to the bottom of this post...please help if you can! chat.cpp CPP / C++ / undefined reference to C Code:
/* CPP Final Projekt JMVermillion chat.cpp If they can do it, so can I. 24 hours! All of the WinSock routines were blatantly butchered from Open-Source code. Thanks to the authors. :) */ #includeusing namespace std; #include "chat.h" CComm::CComm() { ListenSocket = INVALID_SOCKET; // Start with INVALID socket. Ease of use. /* Check to see if it's a Windows machine. If not, don't worry. */ #ifdef _WIN32 // Why does Windows *need* WinSock? Who knows... WORD VersionRequested = MAKEWORD(1,1); WSADATA wsaData; WSAStartup(VersionRequested, &wsaData); // starts the Winsock service if ( wsaData.wVersion != VersionRequested ) { cout << "Error Code \"MICROSOFT\": Wrong version or WinSock not loaded!\n"; } #endif } CComm::~CComm() { if ( ListenSocket != INVALID_SOCKET ) closesocket( ListenSocket ); // Was there a socket? Close! #ifdef _WIN32 // Windows is the only crappy OS that uses WinSock! WSACleanup(); // WinSock cleanup routine. #endif } bool CCo function? What about a Linux version? After linking, i get an error like C:\DEV-C++\LIB\\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16' How can i provide a .def file for my DLL ? I am having strange problems under Windows XP How do i enable Debugging mode ? When I launch Dev-C++ i get the message saying 'WININET.DLL' or 'MSCVRT.DLL' not found The size of the executable generated is huged, why ? How to use assembly with Dev-C++ ? I am using Windows 98 and I cannot compile Why can't I use conio.h functions like clrsrc()? Because conio.h is not part of the C standard. It is a Borland extension, and works only with Borland compilers (and perhaps some other commercial compilers). Dev-C++ uses GCC, the GNU Compiler Collection, as it's compiler. GCC is originally a UNIX compiler, and aims for portability and standards-compliance. If really can't live without them, you can use Borland functions this way: Include conio.h to your source, and add C:\Dev-C++\Lib\conio.o to "Linker Options" in Project Options (where C:\Dev-C++ is where you installed Dev-C++). Please note that conio support is far from perfect. I only wrote it very quickly. How do I emulate the MS-DOS pause function? There are two ways. You can do it this way: #include
What about a Linux version? There was a Linux version, but it has been abandoned, mainly because Dev-C++ is written in Delphi, but the Linux version of Delphi (Kylix) wasn't as promising as it should have been. But there are excellent alternative IDEs for Linux, such as KDevelop and Anjuta. If I have to choose between those two, I would choose for Anjuta. Though personally I don't use an IDE at all, just messing around with 3 terminals and gEdit with autoident. ;-) After linking, i get an error like C:\DEV-C++\LIB\\libmingw32.a(main.o)(.text+0x8e): undefined reference to `WinMain@16' You probably haven't declared any main()
int main()
{
printf ("Press ENTER to continue.\n");
getchar (); // wait for input
return 0;
} Or this way: #include
int main()
{
system ("pause"); // execute M$-DOS' pause command
return 0;
}