QtNetworkモジュールからQtデスクトップアプリケーションに何かを含めると、含まれているものが使用される前に、大量のエラーが発生するという奇妙な問題があります。たとえば、QtNetwork / QHostAddressを含めると、次のエラーが発生します。
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qabstractsocket.h:66: error: template with C linkage
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qabstractsocket.h:253: error: declaration of C function 'QDebug operator<<(QDebug, QAbstractSocket::SocketState)' conflicts with
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qabstractsocket.h:252: error: previous declaration 'QDebug operator<<(QDebug, QAbstractSocket::SocketError)' here
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qhostaddress.h:141: error: declaration of C function 'QDebug operator<<(QDebug, const QHostAddress&)' conflicts with
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qabstractsocket.h:253: error: previous declaration 'QDebug operator<<(QDebug, QAbstractSocket::SocketState)' here
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qhostaddress.h:148: error: declaration of C function 'QDataStream& operator<<(QDataStream&, const QHostAddress&)' conflicts with
..\..\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtNetwork/qhostaddress.h:141: error: previous declaration 'QDebug operator<<(QDebug, const QHostAddress&)' here
もちろん、私は行を追加しました
Qt += network
私の.pro
ファイルにあるので、これが問題になることはありません。別のモジュール(opengl
)を問題なく含めることができます。
QtNetworkを含むだけのダミープロジェクトを作成することで、Qtのインストール自体に問題がないことをすでに確認しました。それはうまくいきました。
したがって、私のプロジェクトには何か問題があるはずですが、エラーメッセージはこの特殊なケースでのみ発生するため、どのような情報を提供するかわかりません。
私が言えるのは、プログラムは以前は純粋なCコードでしたが、現在はQtを使用してC ++に変更されているため、まだ混合されています。ただし、QtNetworkが含まれていない限り、これは問題にはならないようです。
これを解決する方法や、この問題に関連する情報について何かアイデアはありますか?