From owner-freebsd-questions@FreeBSD.ORG Fri Dec 16 15:31:31 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 2DE4116A41F for ; Fri, 16 Dec 2005 15:31:31 +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 0402443D58 for ; Fri, 16 Dec 2005 15:31:29 +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 jBGFVS0t093347; Fri, 16 Dec 2005 10:31:28 -0500 (EST) (envelope-from nvidican@wmptl.com) Message-ID: <43A2DDCF.1030708@wmptl.com> Date: Fri, 16 Dec 2005 10:31:27 -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.711 () J_CHICKENPOX_43,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:31:31 -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" > > > gcc assumes a '.C' file is ANSI C, not C++, try: mv hello.C hello.cpp && gcc -o hello.exe hello.cpp simple hellow world: #include using namespace std; int main(int argc,char* argv[]) { cout << "Hello World!" << endl; return 0; } // end of file Should work - reply if not :) -- Nathan Vidican nvidican@wmptl.com Windsor Match Plate & Tool Ltd. http://www.wmptl.com/