[Solved] Cannot build a project on Mac OSX: error: no member named 'isDetached' in 'QDebug'
-
Hi I think it is a Qt application project. I am a Qt and programming novice, and so I am not sure if my answer is correct. Is there a way to check what kind of project it is?
I am adding a few classes to a pre-existing large project that I receive from my colleagues who are not available at the moment. The project makes a UI and I do some scientific computations for producing some graphics for UI - not sure if this helps.
Thanks for your help!
-
I noticed your Qt path is /usr/local/include/QtCore. Is this really how you installed Qt?
Normally Qt would be installed to say the /usr/local/ prefix but it would be put into something like /usr/local/Qt-5.2.1. Then includes would be gathered from the QTDIR environment variable and directly from qmake settings which you can see with qmake -query.
Anyway, my idea behind this is it's possible you are compiling against a different version of Qt than you expect. Perhaps some version that was installed by some other piece of software. I've never seen Qt installed inside /usr/local/include / lib like that on any posix system.
I've had that happen to me on a linux system before when I wasn't paying attention and it tried to use the existing Qt4 that was installed with KDE instead of the Qt4 that I had wanted it to use.
-
How do you open the project ?
Are you sure it's a Qt 5 ready project ?
-
Yes, I actually have built it OK previously - identical project. Recently, I have installed some python and GPU related stuff for doing some other stuff. When I try to build the same project again today, it all happened. I am positive that it is a Qt 5 ready project.
What I do not understand is that my colleague checked out the same project and built it OK on his Macbook. He does not have the issue with QMessageLogContext being an unknown type. That method seems to be in qlogging.h, which I also have, but for some reason, Qt does not show it as highlighted. I wonder if it is related to configuration issues.
I am opening the project by opening the .pro file for the project.
-
That just makes me think even more that you are using 2 versions of Qt. That is the exact behavior I've seen when that is the problem.
Oh and just for fun, I would run:
- make distclean
- qmake
- make
Sometimes just cleaning the project fixes weird include issues like that.
-
Thanks for your answer, ambershark.
I just ran "make distclean," and qmake and make again.
The errors don't seem to change.To make sure, I ran "make distclean" by changing Projects->Clean Steps->Make arguments from clean to distclean. Then, I ran "Run Qmake" and then rebuilt it. Did I do what you suggested correctly?
-
That should be fine. Are you using Qt Creator? Or some other GUI? I was assuming command line which I really shouldn't do since it seems most people don't use it. :)
-
Yes, I am using Qt Creator and run Qt5.2.1. I am checking if I can find another version of Qt hiding somewhere in the system. Is there a setting or configuration that I can check or clean for Qt?
-
[quote author="kerkil" date="1403805176"]Hi there,
I am trying to compile a project on Mac OSX Mavericks. My Qt version is 5.2.1. (I have Xcode5.1 installed.)
While I build the project, I get these errors:
In file included from ../../../../../Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers/QDebug:1:
../../../../../Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers/qdebug.h:73:9: error: unknown type name 'QMessageLogContext'
QMessageLogContext context;
^
../../../../../Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers/qdebug.h:132:1: error: no member named 'isDetached' in 'QDebug'
Q_DECLARE_SHARED(QDebug)
^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/QtCore/qglobal.h:2215:63: note: expanded from macro 'Q_DECLARE_SHARED'
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); }
~ ^Could someone please help me understand what is causing these errors mean and how to proceed to resolve/fix these errors?
Thanks![/quote]OK, so what I said earlier about 2 different Qt versions seems correct now that I looked at your paths in more detail. If you look at the error it is using the framework for the includes:
../../../../../Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers/qdebug.h
BUT, later on in the build it fails because it included a file from:
/usr/local/include/QtCore/qglobal.h
Just for fun you might try moving/locking/removing your /usr/local/include/Qt* directories.
Be very careful if you choose to remove, something put them there so you will be breaking some other app. What I would do to test this easily is change the permissions so your build can't access them.
On a command line (command+space -> terminal):
sudo chmod 000 /usr/local/include/Qt*
Then try the build. Let me know how it goes, it will probably work.
To restore your permissions:
sudo chmod 755 /usr/local/include/Qt*
If the build works I can help you with a real solution, if it doesn't, post the build log here.
-
Thanks, ambershark for your help!
It fixed the problem! I'd love to learn the real solution so that when this comes back I can fix it by myself!
Thanks a lot and looking forward to learning a real solution.
-
Ah great news!
The solution to your problem is to make sure that your code uses only the includes and libs from your framework and doesn't check the system paths for includes.
To do this with Qt Creator I would have to play around with it. I don't even have it installed right now. But basically you are checking for anything that might set an include path to /usr/local/include. This is sometimes set system wide. It can also be set in CFLAGS/CXXFLAGS environment variables, as well as a few other places.
I'm guessing based on what happened that it is set system wide for you, just a guess though. I would try to figure out what program installed Qt in a system directory like that as it is just going to continue causing you problems.
The problem is basically that /usr/local/include is before your framework include in the path. This causes the compiler to use the headers in /usr/local/include/QtCore rather than the one you expected from the framework.
Solving this problem on your specific system may be difficult. I think my approach if this was my system would be to identify the application that installed the rogue Qt at /usr/local/include and find a fix for that. As a temporary solution you could move all /usr/local/include/Qt* to a backup directory until you find the culprit. Be sure to check for Qt libs in other system places like /usr/local/lib. Something like:
cd /
find . -iname "libqtcore*.so*"That should report any qt lib on your system. Anything in a path you don't think should be there should be moved to a backup directory until you find who uses it. This would be things like /usr/lib /usr/local/lib, etc. It would not include framework paths or wherever you actually installed your legit Qt.
It's also possible your project sets INCLUDEPATH to have /usr/local/include in it. This can be taken out and may solve the problem.
Anway, there are a lot of ways for things to turn out like this and I can't pretend to figure them all out on your system without being able to look around, so my info from above should give you the reasons and some ideas on how to fix but actually finding the specific problem on your system is going to be up to you in the long run.
Good luck! :) At least you can build for now to get your work done. You can always figure the rest out later.
-
Thank you so much, ambershark. I will definitely explore the solutions you suggest, and I agree that at least for now I can focus on getting my work done and always figure things out later! Thanks again for your kind, detailed help!