Mac Xcode 4.5.2 compiling getting algorithm: No such file or directory
-
I'm new to Mac development having come from the Windows side. I'm trying to get a Qt project compiled. I'm getting the following errors in the Qt Creator IDE and when I try to compile on the command line. It looks like a known issue but I've not found an answer that makes any sense at all to me. I'm not sure how to go about installing the clang toolchain. Is there a way to downgrade my Xcode to a version that will work?
I had to make symlinks to g++ in /usr/bin from the Xcode directories. I'm not sure if that was the proper thing to do but it got me past the errors about not being able to find g++.
@lrwxr-xr-x 1 root wheel 59 Nov 13 05:48 /usr/bin/g++ -> /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-g++
lrwxr-xr-x 1 root wheel 76 Nov 12 19:16 /usr/bin/g++-4.2 -> /Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/bin/llvm-g++-4.2@Any an all help is greatly appreciated!
Thanks@My-Mac-Pro:TheDirector SRG$ /Applications/Xcode.app/Contents/Developer/usr/bin/make
g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Qt4.8/mkspecs/macx-g++ -I. -I/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/usr/include/QtCore -I/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/usr/include/QtGui -I/usr/include -I. -I. -I. -F/Library/Frameworks -o accountdetails.o accountdetails.cpp
In file included from /Library/Frameworks/QtCore.framework/Headers/qnamespace.h:45,
from /Library/Frameworks/QtCore.framework/Headers/qobjectdefs.h:45,
from /Library/Frameworks/QtGui.framework/Headers/qwindowdefs.h:45,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
from accountdetails.h:4,
from accountdetails.cpp:1:
/Library/Frameworks/QtCore.framework/Headers/qglobal.h:68:21: error: algorithm: No such file or directory
/Library/Frameworks/QtCore.framework/Headers/qglobal.h:311:34: error: AvailabilityMacros.h: No such file or directory
In file included from /Library/Frameworks/QtCore.framework/Headers/qstring.h:46,
from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:46,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
from accountdetails.h:4,
from accountdetails.cpp:1:
/Library/Frameworks/QtCore.framework/Headers/qbytearray.h:48:20: error: string.h: No such file or directory
In file included from /Library/Frameworks/QtCore.framework/Headers/qobject.h:48,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:46,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
from accountdetails.h:4,
from accountdetails.cpp:1:
/Library/Frameworks/QtCore.framework/Headers/qstring.h:54:20: error: string: No such file or directory
In file included from /Library/Frameworks/QtCore.framework/Headers/qobject.h:50,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:46,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
from accountdetails.h:4,
from accountdetails.cpp:1:
/Library/Frameworks/QtCore.framework/Headers/qlist.h:50:20: error: iterator: No such file or directory
/Library/Frameworks/QtCore.framework/Headers/qlist.h:51:16: error: list: No such file or directory
/Library/Frameworks/QtCore.framework/Headers/qlist.h:58:15: error: new: No such file or directory
In file included from /Library/Frameworks/QtCore.framework/Headers/qlist.h:59,
from /Library/Frameworks/QtCore.framework/Headers/qobject.h:50,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:46,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
from accountdetails.h:4,
from accountdetails.cpp:1:
/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15:25: error: limits.h: No such file or directory
In file included from /Library/Frameworks/QtGui.framework/Headers/qbrush.h:47,
from /Library/Frameworks/QtGui.framework/Headers/qpalette.h:47,
from /Library/Frameworks/QtGui.framework/Headers/qwidget.h:49,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/qdialog.h:45,
from /Library/Frameworks/QtGui.framework/Versions/4/Headers/QDialog:1,
@ -
Sadly, Apple breaks Xcode with almost every new build. It's a real nightmare, the transition. I had to make it (but from linux in my case) a few months ago - I still only use Mac for testing, with all development on linux. Setting it all up took me more than a month (although we have a quite hardcore code in my company, so part of the problem was on our side).
Now, after that short venting, onto the subject (I probably won't remember all the details by now, but at least let's try):
- you can use even the newest Xcode. Compilation is possbile, but requires some tweaking.
- use the newest Qt version available, sometimes it's even good to go ahead and clone the newest code from git
- do NOT use macx-xcode mkspec, it's broken
- both macx-llvm and macx-g++ are OK
- make sure you have command line tools installed (Xcode->Preferences->Downloads)
- make sure xcode-select points to your Xcode installation (I think that is already working in your case)
- just to be sure, you can try forcing the build to use a specific SDK (10.7 and 10.8 seem to be working)
I'm sure there was more to it. Will have a look in a minute and post again.
-
A bit more:
- in some cases, you will need to enforce using g++ as linker instead of Mac's own ld - Apple's software doesn't understand all flags from g++, so you need to invoke it through GCC, and it will translate those flags
- about enforcing the SDK: this can be done with -sysroot <path to SDK> and -isysroot <path to SDK> flags passed to the compiler
That's it for now. Please try it out and report back. It's quite possible we will get it to work together, but might take a few iterations. Best of luck :D
-
Thanks for the reply! Especially so quickly. I have a project that I'm developing in Windows but want it to be cross-platform. Before I invest too much in the dev, I want to make sure I can compile/run in Mac and Linux.
To go down through your points and recommendations:
- I haven't gotten the latest code from git but I am using the latest download from qt-project.org, namely 4.8.3
- I've tried qmake -spec macx-g++ which is what gave me the above errors.
- I did qmake -spec macx-llvm then had to do "ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/llvm-g++ /usr/bin/llvm-g++" so it could find llvm-g++. Same results
- I've never heard of xcode-select before but on doing xcode-select -print-path, I get /Applications/Xcode.app/Contents/Developer
- I'm not sure how to force a specific SDK...
- I'm not sure how to do the first bullet in your "a bit more" section. I'm new here.
- I'm not sure where to find the path to SDK mentioned in your last bullet.
Thanks a lot for helping! I look forward to compiling this and getting a good cross-platform app.
Next, I'll start asking about how to compile for Mac/Linux from the Windows box but that's an entirely different topic.
-
xcode-select seems OK, then. One problem solved :D
The next problem is that I did have the same issues as you here, but I don't remember exactly how this one was fixed. I think it might have been the -sysroot.
run this in terminal:
@
xcodebuild -version -sdk macosx10.7 Path
@It will print the path to SDK 10.7. Then you need to specify this to g++ or clang. We use custom build solution in my workplace, and privately I develop on Linux only, so I'm not perfectly sure how to do it, but try adding something like this to your .pro file:
@
QMAKE_CXXFLAGS+="-sysroot <path printed by xcodebuild>"
@And invoke qmake with:
@
-spec macx-llvm
@I'm going home now, will take me a while to respond + I don't have a Mac at home (luckily :)), but we'll try to move this forward anyway.
-
Added to my .pro file:
QMAKE_CXXFLAGS += "-sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"Ran:
qmake -spec macx-llvm
then ran:
/Applications/Xcode.app/Contents/Developer/usr/bin/makeSame results.
-
The missing files are Mac frameworks and - possibly - STL headers. How did I fix that, now? I can really remember. I definitely tried changing include order and that did push things forward a bit (put -F /Library/Frameworks so that it resides at the beginning of QMAKE_CXXFLAGS), but was not the definite solution. Try adding -isysroot option, too, just like the above. But those are all blank shots on my part.
You could verify if standard C++ works, too, by running g++ on a file like:
@
int main () {
printf("Blah", NULL);
return 0;
}
@ -
Hmm. On a lark, I uninstalled everything related to Xcode and reinstalled Xcode, then the command line tools. It seems to be working so far. Happy day.
Thanks for all of the help!
-
Haha, good! Glad it worked for you.