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.
16 43675
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
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
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.
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
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.
Egad! I didn't see you were using Cygwin.
You still have an incorrect project setup
But my instructions were for Visual Studio.
Sorry.
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
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
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: -
all: nurseryTest
-
all: nursery
-
clean:
-
rm *.o nurseryTest
-
rm *.o nursery
-
-
nursery.o: nursery.cpp nursery.h
-
g++ -c nursery.cpp
-
-
nurseryTest.o: nursery.cpp nursery.h
-
g++ -c nurseryTest.cpp
-
-
nurseryTest: nurseryTest.o nursery.o
-
g++ -o nurseryTest.cpp nursery.o -o nurseryTest
-
-
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
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.
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() {
}
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.
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: -
int main() {
-
// Code here.
-
return 0;
-
}
-
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.
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. -
int main( int argc, char *argv[] )
-
{
-
//...
-
return 0;
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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();
|
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...
|
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...
|
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 ...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |