From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20975 invoked by alias); 31 May 2011 05:49:12 -0000 Received: (qmail 20962 invoked by uid 22791); 31 May 2011 05:49:11 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 May 2011 05:48:51 +0000 Received: from wpaz5.hot.corp.google.com (wpaz5.hot.corp.google.com [172.24.198.69]) by smtp-out.google.com with ESMTP id p4V5mnNt017828 for ; Mon, 30 May 2011 22:48:50 -0700 Received: from pwi8 (pwi8.prod.google.com [10.241.219.8]) by wpaz5.hot.corp.google.com with ESMTP id p4V5mluW017673 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Mon, 30 May 2011 22:48:48 -0700 Received: by pwi8 with SMTP id 8so2758250pwi.22 for ; Mon, 30 May 2011 22:48:47 -0700 (PDT) Received: by 10.68.24.201 with SMTP id w9mr2033835pbf.262.1306820927740; Mon, 30 May 2011 22:48:47 -0700 (PDT) Received: from coign.google.com (adsl-71-133-8-30.dsl.pltn13.pacbell.net [71.133.8.30]) by mx.google.com with ESMTPS id c5sm3445956pbj.41.2011.05.30.22.48.46 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2011 22:48:47 -0700 (PDT) From: Ian Lance Taylor To: "Her\, Il" Cc: "gcc-help\@gcc.gnu.org" Subject: Re: Undefined reference to template function ... References: <7758AFD4380CD24F86D3266E0D083A0550544AF1C8@GVW1160EXB.americas.hpqcorp.net> Date: Tue, 31 May 2011 08:53:00 -0000 In-Reply-To: <7758AFD4380CD24F86D3266E0D083A0550544AF1C8@GVW1160EXB.americas.hpqcorp.net> (Il Her's message of "Mon, 30 May 2011 00:22:19 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true 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: 2011-05/txt/msg00439.txt.bz2 "Her, Il" writes: > I experienced "undefined reference to template function ." when I am compiling my program > with gcc 4.1.2. > > Almost everyone says > that's because template functions weren't be implemented in the same unit where they are > prototyped. (I used .cpp file for implementation and .h file for declaration). > > But, It works if I use gcc 3.4.6 compiler without any change of options. > Why is this happening?... > I am working with my customer, I can't make them understand the common rule for using template > because it works on gcc 3.4.6. > > Can you explain this situation to me? > (Something like it is changed after 4.0 or you have any options to avoid this.) It's impossible to give you a precise answer without a small example. You may find it helpful to read http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Template-Instantiation.html Ian