From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7915 invoked by alias); 28 Oct 2002 11:12:43 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 7811 invoked from network); 28 Oct 2002 11:12:38 -0000 Received: from unknown (HELO postino.fi.infn.it) (192.84.145.9) by sources.redhat.com with SMTP; 28 Oct 2002 11:12:38 -0000 Received: from pc213-02.inwind.it (pc213-02.fi.infn.it [193.206.190.187]) by postino.fi.infn.it (8.12.6/8.12.6) with ESMTP id g9SBCSIt005516; Mon, 28 Oct 2002 12:12:30 +0100 (CET) Message-Id: <5.1.1.6.2.20021028121034.00ba3450@popmail.libero.it> X-Sender: fwyzard-gcc@libero.it@popmail.libero.it Date: Mon, 28 Oct 2002 03:12:00 -0000 To: Baraclese From: Andrea Bocci Subject: Re: c++ compilation error (undefined reference) Cc: gcc-help@gcc.gnu.org In-Reply-To: <3DBC894B.1000905@baraclese.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-RAVMilter-Version: 8.3.1(snapshot 20020109) (postino.fi.infn.it) X-Spam-Status: No, hits=-2.3 required=6.5 tests=IN_REP_TO,DOUBLE_CAPSWORD version=2.31 X-SW-Source: 2002-10/txt/msg00340.txt.bz2 The compiler is telling you that it cannot find the TGA constructor. Well, can't blame it, you didn't provide one :-) IIRC, to get the default constructor (doing nothing but allocating the class itself, more or less) and esructor (idem), you sould not declare them. If you do, the compiler expect you do define them, too, hence the link error. fwyzard At 01.48 28/10/2002 +0100, Baraclese wrote: >Hi, I wrote a TGA header file and I wanted to test it with a small main file. >tga.h looks something like this: >class TGA >{ > public: > > TGA(); > TGA(char *filename); > ~TGA(); > > bool load(char const *filename); >} > >tga.cpp looks like this: > >#include "tga.h" >using namespace std; > >main() >{ > TGA image; > > cout << "Filename: "; > cin >> image.filename; > > if (image.load(image.filename)) > cout << "File successfully read./n"; > return 0; >} > >When compiling using gcc 3.2 I receive the following error message: > >$ g++ -mno-cygwin -lstdc++ f:/projects/cpp/tga.cpp -o tga.exe >/cygdrive/c/WIN98/TEMP/cccSDKcK.o(.text+0x9f0):tga.cpp: undefined >reference to `TGA::TGA()' > >What's the problem here? > >regards, >Baraclese