在 OSX 10.10 Yosemite 上编译 QT5.3 时调用函数不明确

Call to funtion ambiguous when Compiling QT5.3 on OSX 10.10 Yosmite

我正在尝试在 OSX 10.10 上编译 qt5.3。当我 运行 "make" 我得到以下错误:

>cd widgets/ && ( test -e Makefile || /Volumes/Untitled/5.3/Src/qtbase/bin/qmake /Volumes/Untitled/5.3/Src/qtbase/src/widgets/widgets.pro -o Makefile ) && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_NO_USING_NAMESPACE -DQT_BUILD_WIDGETS_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_STYLE_WINDOWSVISTA -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_GTK -DQT_NO_STYLE_WINDOWSCE -DQT_NO_STYLE_WINDOWSMOBILE -DQT_NO_STYLE_ANDROID -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../../mkspecs/macx-clang -I. -I../../include -I../../include/QtWidgets -I../../include/QtWidgets/5.3.0 -I../../include/QtWidgets/5.3.0/QtWidgets -Idialogs -I.uic -I../../lib/QtGui.framework/Versions/5/Headers -I../../lib/QtGui.framework/Versions/5/Headers/5.3.0 -I../../lib/QtGui.framework/Versions/5/Headers/5.3.0/QtGui -I../../lib/QtCore.framework/Versions/5/Headers -I../../lib/QtCore.framework/Versions/5/Headers/5.3.0 -I../../lib/QtCore.framework/Versions/5/Headers/5.3.0/QtCore -I.moc -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AGL.framework/Headers -F/Volumes/Untitled/5.3/Src/qtbase/lib -o .obj/qlineedit_p.o widgets/qlineedit_p.cpp
widgets/qlineedit_p.cpp:352:15: error: call to 'qFuzzyCompare' is ambiguous
    setCursor(qFuzzyCompare(m_opacity, 1.0) || !parentWidget() ? QCurso...
              ^~~~~~~~~~~~~
../../include/QtCore/../../src/corelib/global/qglobal.h:725:37: note: 
      candidate function
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
                                    ^
../../include/QtCore/../../src/corelib/global/qglobal.h:731:37: note: 
      candidate function
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
                                    ^
../../include/QtGui/../../src/gui/painting/qmatrix.h:160:13: note: candidate
      function
inline bool qFuzzyCompare(const QMatrix& m1, const QMatrix& m2)
            ^
../../include/QtGui/../../src/gui/painting/qtransform.h:332:13: note: 
      candidate function
inline bool qFuzzyCompare(const QTransform& t1, const QTransform& t2)
            ^
1 error generated.
make[3]: *** [.obj/qlineedit_p.o] Error 1
make[2]: *** [sub-widgets-make_first] Error 2
make[1]: *** [sub-src-make_first] Error 2
>make: *** [module-qtbase-make_first] Error 2

我使用的配置选项是:

./configure -release -opensource -confirm-license -qt-harfbuzz -qt-zlib -qt-libpng -qt-libjpeg -no-pch -qreal float -nomake examples -nomake tools -verbose -arch x86_64

非常感谢任何帮助。谢谢

http://doc.qt.io/qt-5/qtglobal.html#qreal-typedef

您在调用中将 qreal 重新定义为 float。默认为双倍。

调用的行是:

setCursor(qFuzzyCompare(m_opacity, 1.0) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());

m_opacity是qreal,1.0是double。所以调用qFuzzyCompare(float, double)确实是有歧义的。

您有 2 个选择:

  • 不要将 qreal 定义为 float(如您当前的 ./configure 调用)
  • 编辑 qlineedit_p.cpp 并将调用更改为 qFuzzyCompare(m_opacity, (qreal)1.0)qFuzzyCompare(m_opacity, 1.0f)

如果不需要重新定义 qreal 的类型,我会选择它。