473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

21
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 #1
16 43675
Savage
1,764 Expert 1GB
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.
Do you have WinMain in your project?

Savage
Sep 28 '07 #2
gpraghuram
1,275 Expert 1GB
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.
Hi,
Does ur code have a main in it.
I think if u put a main it will be solved.
Thanks
Raghuram
Sep 28 '07 #3
Micko1
21
Hi,
Does ur code have a main in it.
I think if u put a main it will be solved.
Thanks
Raghuram
Thankyou for the replies.

yes it has a main function.
Sep 28 '07 #4
Micko1
21
The full error I am getting is:

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):: undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
make: *** [nurseryTest] Error 1
Sep 28 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
You have created the wrong kind of project.

You have created a Windows application instead of a Console Application.

Do this:

1) Create a Win3e2 project
2) When the wizard appears DO NOT CLICK FINISH!
3) Instead, click Application Settings
4) Select Console Application and Empty Project
5) Now click finish

and off you go.
Sep 28 '07 #6
weaknessforcats
9,208 Expert Mod 8TB
Egad! I didn't see you were using Cygwin.

You still have an incorrect project setup

But my instructions were for Visual Studio.

Sorry.
Sep 28 '07 #7
Savage
1,764 Expert 1GB
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.
Is your cygwin compiler of Dev-C++?

Savage
Sep 28 '07 #8
Micko1
21
Is your cygwin compiler of Dev-C++?

Savage
I am unsure what you mean?

It is just the regular Cygwin that you get off the website...

Basically I need this program to compile in a unix environment
Sep 29 '07 #9
RRick
463 Expert 256MB
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#OV-EX-WIN for more info. Refer to section 4.1.2
Sep 29 '07 #10
Micko1
21
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#OV-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 Expert 256MB
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
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 Expert 8TB
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 Expert 256MB
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 100+
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
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
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...
0
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...
6
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...
1
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...
3
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
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...
4
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...
1
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 ...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.