473,803 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ERROR: "undefined reference to `_WinMain@16'" when compiling in Cygwin

21 New Member
Hello there :)

I have been using Visual Studio on a program which I have just completed, however I need to have it compiling using a unix based compiler, when I try in cygwin, I get the following error:

undefined reference to `_WinMain@16'

I have tried searching for a workaround, although I am not a programming guru, and I find it difficult to comprehend the discussions on this topic :)

Any help is appreciated.
Sep 28 '07
16 43735
Micko1
21 New Member
Try adding -mwindows to your gcc compiler command.

Take a look at this link http://www.ee.adfa.edu .au/staff/hrp/webDesignHelp/cygwin-ug-net-nochunks.html#O V-EX-WIN for more info. Refer to section 4.1.2
I tried adding that command into my make file ( I think i did it right) but to no avail.

this is my make file:



Expand|Select|Wrap|Line Numbers
  1. all: nurseryTest
  2. all: nursery
  3. clean:
  4.     rm *.o nurseryTest
  5.     rm *.o nursery
  6.  
  7. nursery.o: nursery.cpp nursery.h
  8.     g++ -c nursery.cpp
  9.  
  10. nurseryTest.o: nursery.cpp nursery.h
  11.     g++ -c nurseryTest.cpp
  12.  
  13. nurseryTest: nurseryTest.o nursery.o
  14.     g++ -o nurseryTest.cpp nursery.o -o nurseryTest
  15.  
  16.  
As you see I have 3 files:

nursery.h
nurseryTest.cpp
nursery.cpp

I am not even sure if the makefile itself is correct, but I'm assuming it is because it creates the object files. When I add the gcc -mwindows line I get lots of errors, perhaps I am adding it wrong.

Cheers
Sep 30 '07 #11
RRick
463 Recognized Expert Contributor
Try adding the -mwindows to the g++ command. I would suggest also adding -Wall (turns on warnings). If you plan to debug the program using one of the GNU debuggers, then the following is useful (-g -O0) <--Oh-zero. These options are usually put just after the command and before the file information.

You will need the -mwindows option only for the command that makes the program. The other options are needed for all compilations.

The url link also used the program's resource file (xxx.res) during the linkage of the program. I'm not real familar with the .res file, but I know it is used for windows gui applications.
Sep 30 '07 #12
mseneta
1 New Member
I was receiving the same error, and I think it was due to having my main function in the wrong format.

I had originally had it formatted like this:

void Main()
{
}

When I changed the format to the following, the error went away:

main() {
}
Oct 23 '08 #13
JosAH
11,448 Recognized Expert MVP
Main != main (C and C++ are case sensitive languages) and congrats for
resurrecting a thread that has been dead for almost 13 months.

kind regards,

Jos

ps. and make that 'int main()' as well if you don't want to look silly.
Oct 23 '08 #14
boxfish
469 Recognized Expert Contributor
I'm glad you fixed your error, but it doesn't have anything to do with where the braces are. However, I do approve of having the opening brace on the same line as the function name. main should be written like this:
Expand|Select|Wrap|Line Numbers
  1. int main() {
  2.     // Code here.
  3.     return 0;
  4. }
  5.  
Oct 23 '08 #15
TamusJRoyce
110 New Member
Ah. Thread has been down for over 6 months?

C++ is case sensitive and must have been trying to use the Main() Function which I believe is a backwards WinMain() used back in the Windows 3.1 era, but not sure about that.

I would offer you to use MinGW if you are wishing to do c++ programming with an open source compiler. Cygwin has many problems that can happen with it. Though this is my opinion.

I'd use:
1. CodeBlocks (supersedes Dev-Cpp & cross OS compatable)
- This uses MinGW as opposed to cygwin
2. Visual Studio Express
3. CoLinux/AndLinux - use linux kernal/OS on top of windows

Oh well. Don't mind replying to a re-opened thread.
Oct 24 '08 #16
htake
1 New Member
Hi there.

I just got the same error in cygwin/gcc and found this thread. As noted the reason is that the "main" function with the proper signature was not supplied. I am using the following though, thanks anyway.

Expand|Select|Wrap|Line Numbers
  1. int main( int argc, char *argv[] )
  2. {
  3.     //...
  4.     return 0;
  5. }
  6.  
Jan 14 '12 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7773
by: Steven T. Hatton | last post by:
Scroll to the bottom and read the last part first. I've been trying very diligently to 'modularize' the code from TC++PL3E found here: http://www.research.att.com/~bs/matrix.c I keep getting what I believe are linker errors. For example: g++ -g -O2 -o rematrix cslice_iter.o main.o matrix.o rematrix.o slice_iter.o rematrix.o(.text+0x29b): In function `f(int, int)':
0
1305
by: howie | last post by:
I've upgraded a vb6 application to vb .net and am having an issue. whenever I try to set the recordset property of the VB6.adodc object in .net and run the application I get the error “object reference not set to an instance of an object” this is what the code looks like Dim lador_JLD As New ADODB.Recordset ls_sql = "execute sp_ShiftEditJobsDetail " Dim Gdf_cpv As Object
6
6248
by: mihailsmilev | last post by:
Hello, let me first describe the situation: I am developing an application using Qt Designer 3.3.5 on OpenSuSE Linux for my mp3 player. So I need to get the id3 tags from the mp3 files, and I've downloaded the sources of id3lib. I've included the headers (there are no other files) in my project in Qt designer, then created an object from my files. When starting the make command, it compiles normally all the headers (although giving some...
1
3220
by: Shuaib | last post by:
Hey! I am trying to embedd python into a C programe of mine. But when I try to compile the C code, gcc gives errors like "undefined reference to `Py_Finalize'" and the same kind for all the other functions. I have incuded "Python.h". Any idea what might be wrong? Thanks.
3
2057
by: s.z.s | last post by:
Hi! I hope the solution to that is not too stupid... I've got three files: <snip test_main.cc> #include"test.hh" int main(void) { A<inta1; a1.saywhat();
8
1948
by: Soneji | last post by:
Hello all! ( again ) Once more, I have a problem that seems unsolvable by me. I'm getting the, seemingly common, "undefined reference" linking error. I've tried quite a few things, but nothing is working. I'll list what I've tried at the end of my post. Until then, here's the error message, and the code ( Sorry...( length ) ) :
4
1714
by: steve | last post by:
Hi, I am trying to compile a sample program using gcc. The program requires headers so I put the header files and corresponding source files into one folder. Then I ran the command 'gcc prog.c -o prog.exe.' It then gives me errors such as "undefined reference to '_N_VNew'" where N_VNew is in the header files I put in the folder. Usually gcc file.c -o file.exe worked for a c program that include no user defined headers. I've never dealt...
1
2146
by: ashjas | last post by:
Hello, i am trying to compile a code(main.cpp) which uses a function that is declared in a header file that is within the directory where the main.cpp file resides so the header is included as #include"abc.h" that function's definition is inside abc.cpp that also resides in the directory of main.cpp i.e with abc.h but still on usage of that function i get "undefined reference to" that function error.... How is this possible??
8
6303
Motoma
by: Motoma | last post by:
Good evening everyone. I am starting to re-explore C++, and I wanted to build a singleton class. Unfortunately, when I set things up as I do in PHP, it doesn't work out for me. I hope that the problem is something small and obvious, but here is what I have: #include <iostream> using namespace std; class ClientManager {
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9566
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10300
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.