QT Creator - iostream no such file or directory (Mac) - macos

I have program in QT Creator3.4.2 (Macbook El Capitan).
The line #include <iostream> was under lined and says no such file or directory.
How to resolve this issue ?

Its because I just updated the XCODE and haven't accepted the terms and condition.
I just accepted the T&A and restarted, its works fine now...

Related

GCC won't compile anything on macOS

Recently (since Catalina was released and xcode updated, but I am still running Mojave) I have found the gcc, installed via macports, has broken. I get errors saying that the system includes cannot be found:
ld: library not found for -lSystem
I have tried the solution here: Can't compile C program on a Mac after upgrade to Mojave - but when I install macOS_SDK_headers_for_macOS_10.14.pkg it doesn't actually create anything in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ; all I see in there is the 10.15 (Catalina) sdk!
If I instead just sym link MacOSX10.14.sdk to MacOSX10.15.sdk (possibly not a great idea), I get a different set of errors:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
from /opt/local/include/gcc8/c++/cwchar:44,
from /opt/local/include/gcc8/c++/bits/postypes.h:40,
from /opt/local/include/gcc8/c++/iosfwd:40,
from /opt/local/include/gcc8/c++/ios:38,
from /opt/local/include/gcc8/c++/ostream:38,
from /opt/local/include/gcc8/c++/iostream:39,
from /Users/pae9/soft/src/cmake/LIGO_support/restrictHealMap.cpp:4:
/opt/local/lib/gcc8/gcc/x86_64-apple-darwin18/8.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
char *ctermid(char *);
In other words, now it appears that the macports headers are conflicting with the xcode ones.
I never had a problem before; I think this issue dates to the last xcode update (currently on Version 11.2 (11B52))
Any thoughts or suggestions very welcome - I'd really like to be able to go back to compiling code using gcc!
FYI I'm using gcc7 (from macports), for consistency with the linux servers which are my actual live systems, but I have tried gcc 8 and 9 and get the same results.
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
sudo ln -s MacOSX10.15.sdk MacOSX10.14.sdk
OK, it seems that if I do the ln -s as above, and also move #include to be the first include in all my files, the problem goes away.
This looks to me like a serious problem in the Apple SDK headers, because surely conflicting definitions like this shouldn't occur...?

Xcode command line tools some headers missing

I recently upgraded my Xcode command line tools and now I get errors when compiling stuff that compiled before the upgrade.
tools/px.c:7:10: fatal error: 'unistd.h' file not found
#include <unistd.h>
^~~~~~~~~~
Before this upgrade, whenever I installed a new release of Xcode, I had to install the command line tools and additionally
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
After the latest upgrade, that file and the directory containing it does not exist any more.
I was able to find the package on another machine where I have not yet upgraded.
Nevertheless the issue remain unsolved.

"no such sysroot directory" while building qt project

MacOS Mojave Version 10.14 (18A389).
Today I updated Xcode to version 10.0 (10A255). End when I try to build my Qt project I get an error:
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk' [-Wmissing-sysroot]
In file included from ../greed/timediagram.cpp:1:
In file included from ../../../Qt/5.9.1/clang_64/lib/QtGui.framework/Headers/QtGui:3:
In file included from /Users/arsenyspiridonov/Qt/5.9.1/clang_64/lib/QtGui.framework/Headers/QtGuiDepends:3:
In file included from /Users/arsenyspiridonov/Qt/5.9.1/clang_64/lib/QtCore.framework/Headers/QtCore:4:
In file included from ../../../Qt/5.9.1/clang_64/lib/QtCore.framework/Headers/qglobal.h:47:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:202:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
^~~~~~~~~~
1 error generated.
make: *** [timediagram.o] Error 1
16:13:47: Процесс «/usr/bin/make» завершился с кодом 2.
Ошибка при сборке/установке проекта greed (комплект: Desktop Qt 5.9.1 clang 64bit)
Во время выполнения этапа «Сборка»
What's the problem? How to fix it?
add 'QMAKE_MAC_SDK = macosx10.14' to your .pro file, and manually delete .qmake.stash from your build directory (or directories).
In my case I updated xcode to the last version, so instead of have on the folder the version 10.13, I had MacOSX10.14.sdk ( that is a symbolic link to the folder MacOSX.sdk)
so, you can solve the problem with this code on terminal:
sudo ln -s MacOSX.sdk/ MacOSX10.13.sdk
positioned on the current folder.
I hope it helps.
I just reinstalled Qt. All is Ok now
This helped me:
Close the project in Qt Creator.
Delete the .pro.user file in your code directory.
Add QMAKE_MAC_SDK = macosx10.14 and QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14 to your .pro file in a text editor (not in Qt Creator). Replace 10.14 with whatever MacOS version you want to build for.
Re-open the project in Qt Creator. It will reconfigure.
Build.
Adding to sellen's Answer: If you have trouble locating your .qmake.stash file, or if you don't have a .qmake.stash file in your build folder, try locating it using the terminal:
find /path/to/base/folder -name ".qmake.stash"
In my case I had a .qmake.stash file in my build parent folder, but not in my build folder. Not sure how it got there but somehow QMake picked it up and as soon as I deleted it and restarted Qt Creator things started to work again.
the fast solution is to create new shotcut in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs folder, you can copy the exist shortcut, them change the name you need.
This happen to me recently and my Xcode needed to update. So I would recommend quitting xcode and trying to update your current version to see if that fixes your problem.

QFileDialog::getOpenFileName doesn't set the initial directory on Mac OS 10.8 Mountain Lion

I can not change the current directory with QFileDialog with Qt 4.8. The same code works fine on Windows and Mac OS 10.6 Snow Leopard. It also works fine if I don't use the native Mac OS X dialog.
This works:
fn=QFileDialog::getOpenFileName(this,"Select File","/Users/myuser/Desktop",QString(),0,QFileDialog::DontUseNativeDialog);
This doesn't work:
fn=QFileDialog::getOpenFileName(this,"Select File","/Users/myuser/Desktop");
It looks like if most of the time it opens the last path of the last call to getOpenFileName.
Got the same issue with Qt5.2.0 on Mavericks...
I found a work around: append a dummy file name to the directory you want to select.
However, be sure not to do this on Windows because the user will see it.
QString dir = "/Users/myuser/Desktop";
#if defined(__APPLE__)
dir += "/MyFile.txt";
#endif
fn = QFileDialog::getOpenFileName(this, "Select File", dir);
Also, for those like me that instantiate a file dialog because they need more options you can also do:
QFileDialog fileDialog(this, "Select File");
#if defined(__APPLE__)
fileDialog.selectFile(dir + "/MyFile.txt");
#else
fileDialog.setDirectory(dir);
#endif
...
This is a bug in Qt that is reportedly fixed in Qt 5.0.1 and Qt 4.8.4 (though it seems that it still reproducible in 4.8.4 by people (myself included)).
This bug has been reported in JIRA as QTBUG-20771, QTBUG-28161 and finally QTBUG-35779 (which appears to have finally fully resolved the issue in Qt 5.2.1). Here is a link to the patch in Gerrit.

OpenCV - where are cv.h, core.hpp, highgui.hpp and other file includes?

Most every sample piece of code in OpenCV starts with these lines (or something similar):
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
And yet, these files are not in the opencv installation package? I've installed opencv several times and cannot find these files on my computer. What's going on? How can something so fundamental be missing?
On Windows, they are often within the build/include/opencv directory.

Resources