delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/29/17:27:18

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Originating-IP: [216.103.84.124]
X-Originating-Email: [millervance AT hotmail DOT com]
From: "Vance Miller" <vancemiller AT pobox DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Additional Info on undefined reference to `_WinMain AT 16'
Date: Tue, 29 Jul 2003 14:26:43 -0700
Message-ID: <000401c35618$1b96d720$8300a8c0@QUATTRO4>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Importance: Normal
X-OriginalArrivalTime: 29 Jul 2003 21:26:47.0729 (UTC) FILETIME=[1DE58210:01C35618]
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h6TLRHB22870

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 AT 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 AT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019