From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25325 invoked by alias); 27 Mar 2008 16:11:13 -0000 Received: (qmail 25307 invoked by uid 22791); 27 Mar 2008 16:11:13 -0000 X-Spam-Check-By: sourceware.org Received: from gv-out-0910.google.com (HELO gv-out-0910.google.com) (216.239.58.191) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 27 Mar 2008 16:10:51 +0000 Received: by gv-out-0910.google.com with SMTP id r4so949928gve.10 for ; Thu, 27 Mar 2008 09:10:47 -0700 (PDT) Received: by 10.142.215.5 with SMTP id n5mr1297223wfg.177.1206634245795; Thu, 27 Mar 2008 09:10:45 -0700 (PDT) Received: by 10.142.172.5 with HTTP; Thu, 27 Mar 2008 09:10:45 -0700 (PDT) Message-ID: Date: Thu, 27 Mar 2008 16:11:00 -0000 From: "Koyel Mukherjee" To: gcc-help@gcc.gnu.org Subject: newbie question on linking classes MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00262.txt.bz2 Hi I am a newbie on using gcc and linking files. I have defined some classes (.h and .cpp files) which I want to use in my main function defined in a source file(containing the main() function. I have kept all the class files (.h and .cpp) along with the .cpp source file in one directory. When I compile only using : g++ source.cpp it compiles fine. However, when I try to link it too, by writing: g++ source.cpp -o source_e I get a series of errors containing : undefined reference to func (say) where func is say, a function I have declared in one of my class files. It seems that it is not able to link properly . I have included the header files of the classes in the source file. However I am still getting this error. I tried specifying the directory where all these files are by the -B option but it did not help either. Please help me out! Thanks a lot. Regards Koyel