Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iostream: no such file or directory

I am working with Qt Creator on Windows Vista. I am trying to compile very simple ".cpp" code that includes the standard C++ library "iostream", like this:

#include <iostream>
using namespace std;

int main(){
    cout << "thanks";
    return 0;
}

The problem comes even before compiling the code. It comes when Qt highlights the library and acknowledge me that (iostream: no such file or directory).

It was working fine a couple of days ago, but then I installed Visual Studio 2012 Express which I then uninstalled because, surprisingly, it does not work with Windows Vista. Immediately after the removal of Visual Studio 2012, C++ libraries are not seen by Qt Creator any more.

Note that I can still compile and run my previous written code by a command-line console, which means C++ libraries haven't been removed with the removal of Visual Studio 2012! In addition, all my previous code (within old projects which were created using the same Qt) has no such problem (i.e., Qt identifies and sees the standard libraries), and I can still compile and run them normally using Qt Creator, even when I create a new ".cpp" file within those old projects:

Enter image description here

However, when I create a new ".cpp" file within a totally new project, libraries disappear and a link is missing:

Enter image description here

(I don't want to get used to reinstall Qt each time I have a similar problem with the compiler, I would like to understand why this is happening in the first place.)

So, what exactly is Qt looking for (or where I should be looking at)?

like image 684
McLan Avatar asked Apr 08 '13 21:04

McLan


1 Answers

You don't need to reinstall Qt Creator. If you want to use it for running C++ source code, you should first create a project file. Do as follows:

Menu FileNew file or projectNon-Qt projectPlain C++ application.

So that you create a .pro file. Then Qt Creator will be able to find library files <iostream> and the like. See Qt Creator can't find headers (says: "No such file or directory") for a detailed explanation.

like image 151
user123 Avatar answered Oct 15 '22 07:10

user123