This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Additional Info on undefined reference to `_WinMain@16'


Sorry if this info seems a bit too basic, but I spent several hours last
night trying to resolve a linking error while compiling with gcc on Cygwin.

G++ version 3.2 20020927 (prerelease)
Cygwin Net Release 2.340.2.5 installed via the net 2 weeks ago.

Being new to namespaces, I thought it made sense to place my main() within a
named space. This caused the linking error when no main() in the std (or
global) space was available. See below:


$ cat test.cpp
// filename test.cpp
namespace my_namespace
{
int main()
   {
   return 0;
   }
}


Owner@QUATTRO4 ~/project1/p1
$ g++ test.cpp
/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../libcygwin.a(libcmain.o)(.text+0
x7c)
: undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status

This fix was simple enough:

$ cat test.cpp
// filename test.cpp

using my_namespace::CLASS;

int main()
   {
   return 0;
   }

I hope this helps someone.

Vance

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]