Bug 77483
| Summary: | Cannot compile Hello app with c++ using cout | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Need Real Name <beckerdite> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED NOTABUG | QA Contact: | Brian Brock <bbrock> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2002-11-07 20:21:56 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
This is a C++ program, right? So it should use .C/.cxx/.cpp/.c++ extension, not .c. Also, if you are using STL in it, you should use g++ compiler driver, not gcc, so that libstdc++ gets linked in. And last, cout is in std namespace, so you need to write std::cout or add using namespace std; or using std::cout; above main. |
From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705) Description of problem: cannot compile simple hello world app in c++ using gcc and the 3.2 iostream header Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1.Gedit 2.#include <iostream> int main() { cout <<"hello world"); return 0; } 3. Save as test.c 4. gcc test.c Actual Results: Return= test.c:1:21: iostream No such file or directory test.c: In function 'main': test.c:4: 'cout' undeclared (first us in this function) Etc.... Expected Results: My thought is that the code should compile and that somewhere the headers are confused. Additional info: I have explored with gcc -B and cpp -I etc. to try and get the headers to respond correctly we can get the app to compile using C++ and mapping to the backwards directory and using <iostream.h> but that is not the desired method and comes with an error etc.