Ошибка при компиляции
Он издевается. Это C++, поэтому надо использовать g++ и файл переименовать в program.cpp .
а я вот питону хочу поучиться.
нет, это, видимо, кто то с этой прогой поиздевался надо мной. так, ладно, тред этот на сноску.

Это смесь C и C++, также известная как C/C++. Просто в таком виде её надо компилировать уже как C++.
Эх. при компиляции через g++ тонну ошибок ошибок высыпает. буду копаться дальше =)

Читать же надо, как что использовать, а не копировать и пытаться собрать в последний момент. Ошибки линкера, я полагаю:
Не делай так никогда, пожалуйста

Не пиши на суржике — это ни к чему хорошему не приведёт. Толи на том, толи на том — не надо смешивать.
Нужно добавить еще переводов между строками. Иначе квест слишком легкий получается.
А надо «Делаю gcc program.cpp»
Не надо. GCC по расширению файла определит, C это, или C++. В конце концов, можно подсунуть GCC опцию -x lang, где lang — либо c, либо c++, что позволит явно указать, на каком языке пишут в этом файле.
Да что ты говоришь?
Я не знаю, что за скрипт линкера у твоего GCC, что он не подхватывает std::cout и прочие iostreams при компиляции плюсовой программы (пусть даже в ней густо насыпано сишного кода).
Обычный gcc-5.3 из генты, собирается если добавить -lstdc++.
Это понятно, непонятно, отчего её по умолчанию не применяет линкер.
Это понятно, непонятно, отчего её по умолчанию не применяет линкер(при сборке с помощью GNU C Compiler).
Вы откуда такие беретесь?
Это понятно, непонятно, отчего её по умолчанию не применяет линкер(при сборке с помощью GNU C Compiler)
Вы откуда такие беретесь?
Fatal error: iostream: No such file or directory in compiling C program using GCC
Why when I wan to compile the following multi thread merge sorting C program, I receive this error:
![]()
4 Answers 4
Neither <iostream> nor <iostream.h> are standard C header files. Your code is meant to be C++, where <iostream> is a valid header. Use a C++ compiler such as clang++ or g++ (and a .cpp file extension) for C++ code.
Alternatively, this program uses mostly constructs that are available in C anyway. It’s easy enough to convert the entire program to compile using a C compiler. Simply remove #include <iostream> and using namespace std; , and replace cout << endl; with putchar(‘\n’); . I advise compiling using C99, C11 or C18 (eg. gcc -std=c99 , clang -std=c18 etc)
![]()
Seems like you posted a new question after you realized that you were dealing with a simpler problem related to size_t . I am glad that you did.
Anyways, You have a .c source file, and most of the code looks as per C standards, except that #include <iostream> and using namespace std;
C equivalent for the built-in functions of C++ standard #include<iostream> can be availed through #include<stdio.h>
-
Replace #include <iostream> with #include <stdio.h> , delete using namespace std;
With #include <iostream> taken off, you would need a C standard alternative for cout << endl; , which can be done by printf(«\n»); or putchar(‘\n’);
Out of the two options, printf(«\n»); works the faster as I observed.
When used printf(«\n»); in the code above in place of cout<<endl;
When used putchar(‘\n’); in the code above in place of cout<<endl;
Compiled with Cygwin gcc (GCC) 4.8.3 version. results averaged over 10 samples. (Took me 15 mins)
Fatal error iostream no such file or directory что делать

I am trying to find my first compiler to begin coding and compiling files on. I have just downloaded Code::Blocks (after searching for hours and even downloading and trying multiple different compilers (all to which have led to failures and had to be uninstalled)) and coded the following:
Using what I thought was the compiler that is stored in the Code::Blocks files, I tried executing the program with GNU GCC Compiler.
When I tried to build the program, nothing happened. When I tried running the program, an error window popped up telling me that the program hadn’t been built.
Further investigation of the Build Messages lead me to an error statement suggesting the following:
| «fatal error: iostream: No such file or directory.» |
I am trying to get this compiler to work but I don’t know what to do. I’ve tried other compiler options but Build Messages tell me that I don’t seem to have any other compilers.
NOTE: The first line of code (containing ‘#include <iostream>’) was marked since I received the error message in the Build Messages.
How to compile C++ source code ("iostream.h not found" error)?
I do not want to discuss about C++ or any programming language!I just want to know what am i doing wrong with linux ubuntu about compiling helloworld.cpp!
I am learning C++ so my steps are:
open hello.cpp in vim and write this
So, after that i tried in the terminal this
AND the output is
What do you suggest? Any useful step by step guide for me?Thanks!
2 Answers 2
You should use #include <iostream> , not iostream.h ; the .h form is very old and deprecated since years.
You can read more than you probably want to know on the .h vs non-.h forms here: http://members.gamedev.net/sicrane/articles/iostream.html
(Plus, you should write std::cout or have a line using namespace std; otherwise your next error will be about the compiler not finding a definition for cout .)
You should change iostream.h to iostream . I was also getting the same error as you are getting, but when I changed iostream.h to just iostream , it worked properly. Maybe it would work for you as well.
In other words, change the line that says:
Make it say this instead:
The C++ standard library header files, as defined in the standard, do not have .h extensions.
As mentioned Riccardo Murri’s answer, you will also need to call cout by its fully qualified name std::cout , or have one of these two lines (preferably below your #include directives but above your other code):
The second way is considered preferable, especially for serious programming projects, since it only affects std::cout , rather than bringing in all the names in the std namespace (some of which might potentially interfere with names used in your program).