"no such sysroot directory" while building qt project - xcode

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.

Related

How to update sysroot directory for Xcode (after Xcode 12.3 update)

I just updated Xcode to 12.3, but now when I try to build my project it's giving me this error:
I checked the directory listed for the sysroot warning and I saw that now there's a file called iPhoneOS14.3.sdk, but what do I need to change in my project to make it compatible with that instead of iPhoneOS14.2.sdk?
I restarted my computer and everything worked fine.

Can't compile App from Titanium Appcelerator with iOS OpenCV Module

I have an issue that is going on for over a month and I can't find any solution for it.
I created an Appcelerator Titanium Module, which uses the OpenCV framework.
I tried literally everything I found on the internet to make it work, but no sucess.
The module compiles, but it crashes when building the App that uses it.
To dig deep in the problem, I compile the App via CLI using appc run -p ios -l trace to see the whole thing. This is what I get:
[TRACE] ld: framework not found opencv2 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
This happens if I declare the framework in the module.xconfig file, like this:
OTHER_LDFLAGS=$(inherited) -framework opencv2
If I don't declare it in the file, I get:
[TRACE] symbols not found for architecture x86_64 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
Well, the opencv2.framework file is inside the /ios folder in the module.
This is what I tried so far, to put the OpenCV Framework in the project:
OpenCV Official Example for XCode
Compiling it from scratch and then adding to the Project
brew install opencv and then adding it to the project
I configured Framework Search Paths like this:
$(inherited) $(PROJECT_DIR) $(SRCROOT)
Header Search Paths like this:
$(inherited) "$(TITANIUM_SDK)/iphone/include" /usr/local/Cellar/opencv/4.4.0/include (this last one, when installed by brew CLI command.
The Other Linker Flags, is configured like this:
This configuration I got from this tutorial: OpenCV on XCode
And finally, I tried adding the .dylib files from the source of the OpenCV Framework in the project by right-clicking the project's name and Add Files.
So, I tried everything I could find to solve it, but I can't get it to work.
Sorry for the long question, but I am completly out of ideas on how to make this work.
Please, help me!
First of all, the opencv2.framework is copied automatically to the XCode /ios folder (if you selected Copy Files if Needed). BUT, Appcelerator needs 3rd party frameworks to be put on /ios/platform folder. So, I moved it there.
Secondly I added -lz to the Other Linker Flags in Build Settings.
This solved the problem. I must thank the team and developers from TiSlack (An Appcelerator platform community), which helped me through this. Michael and Hans, Thanks!
Here is a video that helped me install OpenCV4 on my Macbook Pro Mojave 10.14.6. I tried installing OpenCV using another video and it led me to getting a linker error that was similar to yours.
Basically, the problem was the path I specified as for my /lib and /include folders.
https://www.youtube.com/watch?edufilter=NULL&v=HxNZEa7Slyk

Qt5 Target conditionals not found

I just updated to the latest version of command line tools in OS X Mavericks and now when compiling my (previously-working) code it throws the following error
> clang: warning: no such sysroot directory:
> '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk'
> In file included from ../QtOpenGL/Main.cpp:1: In file included from
> ../../Qt/5.3/clang_64/lib/QtWidgets.framework/Versions/5/Headers/QApplication:1:
> In file included from
> ../../Qt/5.3/clang_64/lib/QtWidgets.framework/Versions/5/Headers/qapplication.h:45:
> In file included from
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qcoreapplication.h:45:
> In file included from
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qglobal.h:76:
> /Users/BB/Qt/5.3/clang_64/lib/QtCore.framework/Headers/qsystemdetection.h:196:12:
> fatal error: 'TargetConditionals.h' file not found
> # include <TargetConditionals.h>
> ^ 1 error generated. make: *** [Main.o] Error 1 20:29:52: Le processus "/usr/bin/make" s'est terminé avec le code 2. Erreur lors
> de la compilation/déploiement du projet QtOpenGL (kit : Desktop Qt
> 5.3.0 clang 64bit) When executing step "Make"
Does anyone knows that if changing this line
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
from sdk 8 to 9 would work? If so, where in the parameters of Qt5 can I change this?
For other people's reference, I solved the issue by editing my platform mkspec file:
/users/nic/Qt/5.3/clang_64/mkspecs/qdevice.pri
change the following line:
!host_build:QMAKE_MAC_SDK = macosx10.8
to this:
!host_build:QMAKE_MAC_SDK = macosx10.9
Be sure to clean your project and run qmake again.
Nic.
It is possible to compile the project also by adding the following line to the .pro file
QMAKE_MAC_SDK = macosx10.9
If you compile in other platforms than OS X, an improvement of BRabbit27 solution would be:
macx {
QMAKE_MAC_SDK = macosx10.9
}
I just upgraded to XCode 9 and I started getting this problem on macOS Sierra (10.12). The problem is that Xcode moved the default symlink to 10.13. To fix:
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
sudo ln -s MacOSX.sdk MacOSX10.12.sdk
Had the same problem in Qt 5.5, MacOS 10.10.4. I removed .qmake.conf and .qmake.stash from the project directory.
I found out that the file ".qmake.cache" in my project root had a reference to Mac OS 10.8.
The solution was to remove the file and build the project from scratch.
I installed Qt 5.9.1 before I installed Xcode 10.13. Since I upgraded the Xcode, error message with following warning started showing up.
:-1: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' [-Wmissing-sysroot]
I solved the problem changing following line
QMAKE_MAC_SDK = macosx
to
QMAKE_MAC_SDK = macosx10.13
in the following file:
path_where_I_installed_qt/Qt/5.9.1/clang_64/mkspecs/qdevice.pri
I hope it works for you.
For me, deleting the output directory contents manually fixed the issue (Qt 5.9, Xcode9, MacOS 10.12.6). Cleaning/Rebuilding did leave some corrupt stuff.
For Qt 5.8 and iOS build I added symbolic link to sdk in XCode folders:
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
ln -s iPhoneOS.sdk iPhoneOS10.0.sdk
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs
ln -s iPhoneSimulator.sdk/ iPhoneSimulator10.2.sdk
I am using Qt5.8 on macosx10.13, I solved this problem by editing the file /usr/local/Cellar/qt-legacy-formula/5.8.0_1/mkspecs/qdevice.pri by adding this line:
!host_build:QMAKE_MAC_SDK = macosx10.13
I just wanted to comment on this by adding my experience. I recently updated to High Sierra, XCode 9.2, and Qt5.10 and the XCode license message was driving me batty!
In qdevice.pri I changed
QMAKE_MAC_SDK = macosx
to
QMAKE_MAC_SDK = macosz10.13
but that wasn't all that I needed. I had to removed the .qmake.stash and Makefile files from the build directory. I'm not sure removing the Makefile was needed, but I did it anyway. Then I removed the *.pro.user files so that I could force a reconfigure by QtCreator. That forced me or let me select the updated Qt version. Before this I think it was trying to use the older versions of stuff. So, cleaning out all the references to the old stuff in your project and selecting the new is important.
Method 1
This kind of error will appear every time you upgrade Xcode
so you can remove cache file in qt before you build or just remove when you get the error
rm {your target build folder}/.qmake.stash
or
rm {your project folder}/.qmake.stash
if you don't know where to find .qmake.stash, try
find ~ -name .qmake.stash
Method 2
Not recommend because you could get build error when you use Xcdoe APP
iphoneOS
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
sudo ln -s iPhoneOS.sdk iPhoneOS{version}.sdk
iPhoneSimulator
cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
sudo ln -s iPhoneSimulator.sdk iPhoneSimulator{version}.sdk

How to install VTK 6.1 for OSX 10.8 with Cocoa/XCode support?

The extremely helpful guidelines posted at http://www.vtk.org/Wiki/Cocoa_VTK and via the readme file by Sean McBride and Mike Jackson inside the VTK repo were slightly out of date for VTK 6.1. So in case this helps anybody, I'm posting instructions for installing VTK 6.1 on OSX 10.8 with support for the SimpleCocoaVTK Xcode project.
* Installing VTK 6.1 for OSX 10.8 with Cocoa support *
These instructions slightly modify Ryan Glover's instructions at http://www.vtk.org/Wiki/Cocoa_VTK and the README.rtf in the VTK/Examples/GUI/Cocoa/Documentation folder by Sean McBride and Mike Jackson.
Clone the VTK git repo into a directory of your choice:
cd /Users/you/
git clone https://github.com/Kitware/VTK.git
cd VTK
git checkout tags/v6.1.0
make a build directory
mkdir VTKBuild
cd VTKBuild
Run the VTK cmake script
You will now be inside /Users/you/VTK/VTKBuild, run cmake from here (using the parent directory's CMake files):
cmake ..
Edit lots of lines in the newly generated CMakeCache.txt (in the current VTKBuild directory). One issue I had was that there were error if I didn't use a full path for the CMAKE_INSTALL_PREFIX. So make sure to use "/Users/you/" instead of "~":
CMAKE_INSTALL_PREFIX:PATH=/Users/you/VTK/VTKBuild
BUILD_SHARED_LIBS:BOOL=OFF
CMAKE_BUILD_TYPE:STRING=Debug
VTK_USE_SYSTEM_ZLIB:BOOL=ON
CMAKE_OSX_ARCHITECTURES:STRING=i386;x86_64
CMAKE_OSX_SYSROOT:STRING=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
Compile the VTK project (this might take over an hour to run!):
make
Copy headers to an include directory:
make install
VTK should now be completely installed in the VTKBuild directory and ready to use in an XCode project!
Go to your finder, navigate to Users/you/VTK/Examples/GUI/Cocoa/ and double click to open SimpleCocoaVTK.xcodeproj in XCode.
In the XCode menubar (at the top of the screen) Go to Preferences->Locations->Source Trees and use the + button to add in two source trees:
vtk-debug-include vtk-debug-include Users/you/VTK/VTKBuild/include/vtk-6.1
vtk-debug-lib vtk-debug-lib Users/you/VTK/VTKBuild/lib
Click on the XCode project and delete all the references to vtk 6.0:
In the project view, select Targets->SimpleCocoaVTK and then press "Build Phases" and then open the "Link Binary With Libraries". Delete all the files that begin with "libvtk" and end with "6.0.a"
In the file view of the SimpleCocoaVTK project, hightlight and delete all the files in the vtk-libraries folder.
Make sure the XCode file view is active. Then in the finder, navigate to /Users/you/VTK/VTKBuild/lib, and select all the files that begin with "libvtk" and end with "6.1.a". Drag these files into the folder "vtk-libraries" in the XCode file view.
In XCode, do a Product->Clean
You can now build and run the sample SimpleCocoaVTK project.
I also had to set
VTK_WRAP_PYTHON:BOOL=ON
in CMakeCache.txt
It depends on what user you are too on your machine (computer) and the permissions relevant to that user. I did a find and replace on the CMakeCache.txt file and changed all /usr/local references to /Users/myusername/Develop/VTKInstall. That way everything's at your fingertips and you don't have to change permissions on things.
When you open up the Cocoa example make sure to set in you preferences these paths (e.g. Preferences->Locations->Source Trees). Also you'll need to re-import your vtk-libraries into the project.
I'm running Yosemite with XCode 6.1.1. I hope this helps someone!
If you get error messages likes this, when trying to build VTK:
#error: garbage collection is no longer supported
make[2]: *** Rendering/OpenGL/CMakeFiles/vtkRenderingOpenGL.dir/vtkCocoaRenderWindowInteractor.mm.o] Error 1
make1: *** [[Rendering/OpenGL/CMakeFiles/vtkRenderingOpenGL.dir/all] Error 2
You need to remove a flag in the source CMakeLists.txt:
#IF(APPLE)
SET(VTK_OBJCXX_FLAGS_DEFAULT "-fobjc-gc")
SET(VTK_REQUIRED_OBJCXX_FLAGS ${VTK_OBJCXX_FLAGS_DEFAULT} CACHE STRING "Extra flags for Objective-C++ compilation")
MARK_AS_ADVANCED(VTK_REQUIRED_OBJCXX_FLAGS)
ENDIF(APPLE)#
Either outcomment or delete it all together. Then run cmake again in an empty build directory. Check in the generated CMakeCache.txt in your build directory if it contains a key like VTK_REQUIRED_OBJCXX_FLAGS, it shouldn´t, try running cmake in an empty build directory again.
This 'bug' maybe fixed in future VTK versions.
Source: [Solved] Build Qt 5.2.1 + VTK 6.1.0 + CMake 2.8.12.2

C++ and Objective C in Xcode project

I have recently updated Xcode to version Version 3.2.2 (Pre-release). It is working fine with old Objective-C projects but I experience some problems with projects which have mix of Objective-C/Objective-C++ code. During the compilation I am getting the following error:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/c++/4.2.1/bits/functexcept.h:41:28: error: bits/c++config.h: No such file or directory
I have checked the path a compiler complains about and found that file functexcept.h is located in the following path:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/c++/4.2.1/armv7-apple-darwin9/bits/
My question is where I should change that path to correct one in Xcode?
Thanks in advance.
Try to make a symlink pointing arm-apple-darwin10 to arm-apple-darwin9:
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/include/c++/4.2.1/
sudo ln -s arm-apple-darwin9 arm-apple-darwin10
Report a bug to Apple.
After installation of the iPhone SDK with XCode (Version 3.2.1) problem has gone.

Resources