I'm trying to understand how to compile C++ programs from the command line using g++ and (eventually) Clang on Ubuntu.
I found a webpage which explains MakeFiles and I am following their directions. http://mrbook.org/tutorials/make/
I downloaded the four example files into their own directory.
I then went ahead and ran their example of how to manually compile without a MakeFile.
g++ main.cpp hello.cpp factorial.cpp -o hello
When I ran the command from above, I received the following error from g++:
main.cpp:1:22: fatal error: iostream.h: No such file or directory compilation terminated. hello.cpp:1:22: fatal error: iostream.h: No such file or directory compilation terminated.
My only experience with writing c++ is using an IDE such as VS C++ Express or CodeBlocks. Isn't the compiler supposed to know what iostream.h is and where to find it?
How do I get rid of this error so the program willl compile?
Thanks for any help.
This issue is because of latest changes in iOS12. We have already replaced libstdc++(c++ compiler from GNU) to LLVM C++ 11 Support(libc++) for key "CLANG_CXX_LIBRARY "(C++ standard Library in Xcode Build settings) to fix the issue. Our released beta plugins already have this fix.
iostream. h is deprecated by those compilers that provide it, iostream is part of the C++ standard. To clarify explicitly there is no mention of iostream. h at all in the current C++ standard (INCITS ISO IEC 14882 2003).
h> is not supported, remove it. add this line before main using namespace std; or qualify every functuon call to cout with std:: like std::cout remove getch() it is non-standard function Seems like you are stuck with TurboC++ Add the tag as C++ instead of "help". Keep it simple, remove ".
If you don't want to use iostreams, your alternatives are C-style stdio and low level OS-specific functions like write() or WriteFile() .
Before the C++ language was standardized by the ISO, the header file was named <iostream.h>
, but when the C++98 standard was released, it was renamed to just <iostream>
(without the .h
). Change the code to use #include <iostream>
instead and it should compile.
You'll also need to add a using namespace std;
statement to each source file (or prefix each reference to an iostream function/object with a std::
specifier), since namespaces did not exist in the pre-standardized C++. C++98 put the standard library functions and objects inside the std
namespace.
<iostream.h>
has never been a standard C++ header, because it did not make it into the C++ standard.
Instead we got <iostream>
, in 1998.
Steer well clear of teaching material using non-standard stuff such as <iostream.h>
or void main
.
However, as a practical solution for your current pre-standard code, you may try to replace
#include <iostream.h>
with
#include <iostream> using namespace std;
It’s not guaranteed to work, but chances are that it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With