سؤال

I am using Qt-Creator on Mac OS X for C++-development (I don't use Qt itself). The strange thing is, that Qt-Creator is unable to find any files that are directly in /usr/inlcude. Everything still compiles, but I just cannot use features like autocomplete or "Follow symbol under cursor" in Qt-Creator because of that.

So for C++ headers like iostream, everything works as expected, it finds the header files and indexes them correctly. But if I want to use something from unistd.h, Qt-Creator does not find the include directory. I am using clang 5.2 (from Apple) and Mac OS X 10.9.2.

I even tried adding this (redundant) line to my CMakeLists.txt file:

include_directories(/usr/include)

but that does not help. It is nothing I can not live with, but it is still frustrating.

هل كانت مفيدة؟

المحلول

So I found the problem (it is really stupid). I decided to start Qt Creator from the command line. By doing so, I saw error messages from clang which complained about unknown/wrong arguments and this helped me to find the problem. It is IMHO kind of bad that you never see those in the GUI...

So to make C++11 work correctly, I had to go to settings->Build & Run -> Compilers and make a copy of clang and add "-std=c++11 -stdlib=libc++" to the codegen flags. I made a stupid typo there and wrote "-std=c++11 -stdlib=c++" instead. Since Qt Creator still found all header from libc++ and had c++11 activated, I never bothered to double check this. But changing this flag to the correct one did the trick.

EDIT: Just want to add: I found it extremely strange, that Qt Creator was able to find ALL include files (I use several third party libraries at several different locations - no problem there) EXCEPT for those in /usr/include if you screw up these compiler flags.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top