PDA

View Full Version : Using the standard library with qt creator



DragonLance156156
20th May 2009, 20:10
So i'm just learning to program with C++ (hoping to program with qt eventually) and I decided that I would try using the qt creator's code editor. However, the editor says that the standard library headers are non-existant, even though I can compile my programs just fine using terminal. (i'm on a mac) I was just wondering if there was a way to remedy this so I can run my programs in qt creator. I am asumming there is a file path that the editor is looking for them in and it cannot find them. Any help would be great.

lyuts
21st May 2009, 08:25
If you want others to help you you need to be more specific. Show us code, the instructions how did you try to compile it in Qt Creator and in terminal, error output, all possible information.

DragonLance156156
22nd May 2009, 06:13
OK I guess that my first post was a little wordy so I'll just get to the point. Why does the Qt creator not find the standard library headers when you try to use them. Eg:

#include <iostream>
#include <string>
#include <stdexcept>
#inlcude <vector>
all these preprocessor directives get little squiggly red lines under them and if you hover over it the tool tip says "No such file or directory"

What I want to know is where the directory that Qt creator is looking in for these libraries in is so I can add the standard library files. All I want to do is be able to hit the run button and have my program work. Btw, I just opened my .cpp file with qt creator I have no project file.

EDIT: I put my code into the main.cpp generated when I make a Qt console application project (in place of generated code), ran the program and it did everything right until I tried to input something and
std::cin >> n1; wouldn't read my input, I just hit enter and nothing happened. (this is in the program output pane of Qt creator) is there no way to give a program you are running input like you would if it was complied and run in terminal?

kolen
2nd July 2009, 18:31
I have the same problem. Program compiles, but includes are highlighted with warning and completion for standard c++ library does not work.

Update: solved by adding

INCLUDEPATH += /usr/include/c++/4.3 to .pro file. Currently have no idea how to not use absolute path there.

SiL3NC3
28th November 2012, 18:15
thank you dude, was already wondering while learning c++ with qt creator ...

*thumbsup*

moijhd
16th July 2013, 10:21
Hi !

I tried the same include (with a version 4.6) but Qt Creator still don't get the standard c++ includes.

Any ideas ?

I was previously working on Windows and I am now on an Ubuntu. I tried before on a VM and it worked fine. So I assume it is because of the new machine configurations...I don't know where to look

moijhd
16th July 2013, 16:31
It compiles fine but it indicates that the includes point to nothing existing...and I have no autocompletion :)

Infinity
18th July 2013, 22:53
Does the problem occur on Windows or on Ubuntu (or on both systems)?

If the problem occurs only on Windows and you are using MinGW: I had the same problem, my program compiled fine but the header files of the standard library couldn't be found (hence auto completion didn't work). I was using MinGW as compiler and I chose mingw32-make.exe as compiler path. Using gcc.exe instead of mingw32-make.exe solved the problem. Maybe this works for you, too.

ChrisW67
19th July 2013, 07:21
I was using MinGW as compiler and I chose mingw32-make.exe as compiler path.
Why, it is certainly not a C++ compiler.

moijhd
22nd July 2013, 14:21
May it be because it is not in the environment ?

In the PATH variable I do not have /usr/include/c++/4.6.

Infinity
24th July 2013, 17:51
Why, it is certainly not a C++ compiler.
I know, I chose it accidentally. The compilation worked nevertheless (so I didn't noticed that mistake instantly - only auto completion didn't work).


May it be because it is not in the environment ?
Just try to add it.

moijhd
25th July 2013, 08:26
I added it to the environment PATH variable but it changed nothing.

jstar
3rd February 2016, 08:59
On Windows you change environment variables by right clicking My Computer -> Properties -> Advanced -> Environment variables.
Add D:\Program Files\Qt\5.5
Works fine for me.:)