From owner-freebsd-questions@FreeBSD.ORG Fri Dec 16 15:34:08 2005 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B9E1116A42B for ; Fri, 16 Dec 2005 15:34:08 +0000 (GMT) (envelope-from nvidican@wmptl.com) Received: from wmptl.net (fw1.wmptl.com [216.8.159.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE15343D7B for ; Fri, 16 Dec 2005 15:34:03 +0000 (GMT) (envelope-from nvidican@wmptl.com) Received: from [10.0.0.104] (r3140ca.wmptl.net [10.0.0.104]) by wmptl.net (8.13.1/8.13.1) with ESMTP id jBGFXdhe093421; Fri, 16 Dec 2005 10:33:41 -0500 (EST) (envelope-from nvidican@wmptl.com) Message-ID: <43A2DE53.7080207@wmptl.com> Date: Fri, 16 Dec 2005 10:33:39 -0500 From: Nathan Vidican User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Miao References: <979f20140512160709n3530c01dmdad5714f8e30bc00@mail.gmail.com> In-Reply-To: <979f20140512160709n3530c01dmdad5714f8e30bc00@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.111 () RATWR10_MESSID X-Scanned-By: MIMEDefang 2.44 Cc: questions@freebsd.org Subject: Re: C++ compile error X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2005 15:34:08 -0000 David Miao wrote: > Dear list, > > I try to compile a hello world C++ program in FreeBSD 6.0, but get an > error as below: > > [dm@ORION ~/cpp]% CC -o hello hello.C > hello.C: In function `int main()': > hello.C:5: error: `cout' undeclared (first use this function) > hello.C:5: error: (Each undeclared identifier is reported only once > for each function it appears in.) > hello.C:5: error: `endl' undeclared (first use this function) > > I noticed that "iostream" file is located in > "/usr/include/c++/3.4/iostream", I guess my CC compiler cannot find > this head file. Is it true? And how can I fix this problem? Your > advice is appreciated. Thanks in advance. > > ==quote of hello world code== > #include > > int main() > { > cout << "Hello World!" << endl; > > return 0; > } > == end of quote== > > Regards, > David > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > Also, noticed your code is flawed, you never used a namespace, nor explicitly stated one. cout is part of the 'std' namespace, so either ' using namespace std;' for global/local use of namespace, OR do 'std::cout <<' instead. Try the hello.cpp I sent you in the last email, that one should work for ya :) -- Nathan Vidican nvidican@wmptl.com Windsor Match Plate & Tool Ltd. http://www.wmptl.com/