delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/05/18/12:24:22

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
Reply-To: Cygwin List <cygwin AT cygwin DOT com>
Message-Id: <6.1.0.6.0.20040518115246.03278788@127.0.0.1>
X-Sender:
Date: Tue, 18 May 2004 12:18:29 -0400
To: Christian Rudiger <christianruediger AT gmx DOT net>, cygwin AT cygwin DOT com
From: Larry Hall <cygwin-lh AT cygwin DOT com>
Subject: Re: g++ libcygwin.a has an undefined reference
In-Reply-To: <c8cnvd$4bp$1@sea.gmane.org>
References: <c8cn3t$21u$1 AT sea DOT gmane DOT org> <00ae01c43cbf$d7d88d50$350aa8c0 AT pavilion> <c8cnvd$4bp$1 AT sea DOT gmane DOT org>
Mime-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i4IGO95x031229

It's not really strange at all if you think about what you're asking the
compiler/linker to do.  You've asked for an executable but provided no 
entry point.  Without "main()", there is no entry point so linking fails.
You can certainly compile what you have into an object file but an 
executable requires a "main()".  This is in the FAQ BTW.

Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


At 06:23 AM 5/18/2004, you wrote:
>Hello Al,
>
>thank you, it worked.
>i putted one at the end of the program just writing :
>
>}; // end of class
>int main(){}
>
>why does that work? I think thats strange.
>
>Regards Christian Rudiger
>
>Al Slater wrote:
>
>>Try putting a main function in the program!
>>Regards
>>Al
>>
>>>-----Original Message-----
>>>From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf Of Christian Rudiger
>>>Sent: 18 May 2004 11:09
>>>To: cygwin AT cygwin DOT com
>>>Subject: g++ libcygwin.a has an undefined reference
>>>
>>>
>>>Hello there,
>>>
>>>i think the following problem has to do with cygwin, cause libcygwin.a has an undefined reference.
>>>I get the error message when compiling my little testprogram. The Programm and complete compiler messages follow:
>>>
>>>*************************************************************
>>>
>>>// reading a text file
>>>#include <iostream.h>
>>>#include <fstream.h>
>>>#include <stdlib.h>
>>>#include <string.h>
>>>
>>>using namespace std;
>>>
>>>class tryit {
>>>
>>>  char *FILE_POSTFIX;// = new "myfile.txt"; <- ausserhalb nicht möglich
>>>  string posti;
>>>public:
>>>  int main (int argc, char** argv) {
>>>
>>>    FILE_POSTFIX = new char[10]; //"Nodes.txt"; <- erst allocieren dann zuweisen !
>>>    FILE_POSTFIX = "NODES.txt";
>>>    char *filename = FILE_POSTFIX;
>>>    char *output;
>>>    ifstream in (filename) ;
>>>    while (in){
>>>    in >> output ;
>>>    cout << output << endl;
>>>    return 0;
>>>      }
>>>  }
>>>};
>>>
>>>*************************************************************
>>>
>>>g++ -v -Wall -Wno-deprecated tryme.cpp -o testthings.exe
>>>Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
>>>Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --with-gnu-as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/sbin --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,f77,pascal,java,objc --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --without-included-gettext --enable-interpreter --enable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --disable-win32-registry --enable-java-gc=boehm --disable-hash-synchronization --verbose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
>>>Thread model: posix
>>>gcc version 3.3.1 (cygming special)
>>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/cc1plus.exe -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../include/w32api -idirafter /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygw
>>in/lib/../../include/w32api 
>>>tryme.cpp -D__GNUG__=3 -quiet -dumpbase tryme.cpp -auxbase tryme -Wall -Wno-deprecated -version -o /cygdrive/d/TMP/cc55YaOO.s
>>>GNU C++ version 3.3.1 (cygming special) (i686-pc-cygwin)
>>>    compiled by GNU C version 3.3.1 (cygming special).
>>>GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32700 ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/i686-pc-cygwin/include" ignoring duplicate directory "/usr/i686-pc-cygwin/lib/../../include/w32api"
>>>#include "..." search starts here:
>>>#include <...> search starts here:
>>> /usr/include/c++/3.3.1
>>> /usr/include/c++/3.3.1/i686-pc-cygwin
>>> /usr/include/c++/3.3.1/backward
>>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/include
>>> /usr/include
>>> /usr/include/w32api
>>>End of search list.
>>>/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../../i686-pc-cygw
>>in/bin/as.exe 
>>>--traditional-format -o /cygdrive/d/TMP/ccbPwKZW.o /cygdrive/d/TMP/cc55YaOO.s
>>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/collect2.exe -Bdynamic --dll-search-prefix=cyg -o testthings.exe /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../crt0.o /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/crtbegin.o -L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1 -L/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../.. /cygdrive/d/TMP/ccbPwKZW.o -lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/crtend.o
>>>/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../libcygwin.a(lib
>>>cmain.o)(.text+0x7c): undefined reference to `_WinMain AT 16'
>>>collect2: ld returned 1 exit status
>>>make: *** [testthings.exe] Error 1
>>>
>>>Compilation exited abnormally with code 2 at Tue May 18 11:05:17
>>>
>>>
>>>Regards Christian Rudiger
>>>
>>>
>>>--
>>>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/
>>
>
>
>--
>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/


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