Qt と C++ は初めてで、簡単なプロジェクトを作成したいと考えています。私はこのコードを書きました:
#include <QString>
int main()
{
QString str = "a,,b,c";
return 0;
}
そして、私はそれを次のようにコンパイルします:
g++ -o LeapMouse Leapmouse.cpp -I /home/dougui/Qt/5.1.1/gcc_64/include/QtCore -I /home/dougui/Qt/5.1.1/gcc_64/include -fPIE
そして、私はこのエラーがあります:
/tmp/cc6umRmY.o: In function `QString::QString(char const*)':
Leapmouse.cpp:(.text._ZN7QStringC2EPKc[_ZN7QStringC5EPKc]+0x34): undefined reference to `QString::fromAscii_helper(char const*, int)'
/tmp/cc6umRmY.o: In function `QTypedArrayData<unsigned short>::deallocate(QArrayData*)':
Leapmouse.cpp: (.text._ZN15QTypedArrayDataItE10deallocateEP10QArrayData[_ZN15QTypedArrayDataItE10deallocateEP10QArrayData]+0x1e): undefined reference to `QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)'
collect2: error: ld returned 1 exit status
私が行うとgrep -ri 'fromAscii_helper' /home/dougui/Qt/5.1.1/gcc_64/include
、ここでわかるように関数が見つかります:
/home/dougui/Qt/5.1.1/gcc_64/include/QtCore/qstring.h: static Data *fromAscii_helper(const char *str, int size = -1);
含める必要があります。私は何かを逃しましたか?Qt のライブラリを標準の C++ プロジェクトに含めることはできますか?