链接器问题与QString?

时间:2013-08-09 02:43:25

标签: qt linker qml lnk2019

我在使用msvc2012编译qt项目时遇到问题。出于某种原因,它说有一个未解决的符号等同于QString函数,我无法理解。

这是我的.pro文件(这个程序只是命令行,只是为了方便而使用qt

QT       += core gui widgets


TARGET = klc2abuspro
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

SOURCES += main.cpp \
key.cpp \
klayout.cpp \
deadkey.cpp

HEADERS += \
key.h \
klayout.h \
deadkey.h

OTHER_FILES +=

这里是链接器问题引用的地方:

{
QString file;



if(argc < 2)
{

    qDebug() << "No file specified. Defaulting to russian.klc";


    file = "russian.klc";
}
else
    file = argv[1];


QFile input(file);

if(!input.open(QIODevice::ReadOnly | QIODevice::Text))
    qDebug() << "File could not be opened";


    QTextStream in(&input);

    QString str;
    KLayout * layout = new KLayout(file.split(".", QString::SkipEmptyParts)[0]);

    while(!in.atEnd() && !(str = in.readLine()).contains("LAYOUT"));

    in.readLine(); in.readLine(); in.readLine();in.readLine();

    bool currChunk = true;
    while(currChunk)
    {

        str = in.readLine();

        if(str == "")
        {
            currChunk = false;
            break;
        }

        QStringList parts = str.split("\t",QString::SkipEmptyParts );

        layout->addKey(new Key(parts[0].toUInt(0,16),parts[3], parts[4]));

    }



    input.close();










//Starting deadkey finder


if(!input.open(QIODevice::ReadOnly | QIODevice::Text))
    return -1;

QTextStream pass(&input);


while(!pass.atEnd() && !(str = pass.readLine()).contains("KEYNAME_DEAD"));
pass.readLine();

DeadKey * dkeys[10];
int i = 0;
while((str = pass.readLine()) != "") {
    //qDebug() << "Line: " << str;

    QStringList parts = str.split("\t",QString::SkipEmptyParts );

    //1 is the name, 0 is the unicode value of the character
    layout->addDeadKey(dkeys[i] = new DeadKey(parts[1], parts[0]));
    i++;
}

//qDebug() << layout->printDeadKeys();

input.close();



// Find deadkey modifiers
bool cont = true;
i = 0;
input.open(QIODevice::ReadOnly | QIODevice::Text);

do {
    while(!pass.atEnd() && !(str = pass.readLine()).contains("DEADKEY") && !(str.contains("KEYNAME")));

    if(str.contains("KEYNAME")) {

        cont = false;
        break;
    }
    pass.readLine();


    while((str = pass.readLine()) != "") {
        //qDebug() << "Line: " << str;

        QStringList parts = str.split("\t",QString::SkipEmptyParts );

        //1 is the name, 0 is the unicode value of the character
        //qDebug() << "Key to modify: " << parts[0] << "key result: " << parts[1];
        dkeys[i]->addModifier(QChar(parts[0].toUInt(0,16)), QChar(parts[1].toUInt(0,16)));



    }

    i++;
}while(cont);

layout->implementModifiers();


//qDebug() <<layout->printMods();


layout->exportToQML(file.replace(".klc",".qml"));




return 0;
}

链接器错误

main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString & __cdecl QString::operator=(class QString &&)" (__imp_??4QString@@QEAAAEAV0@$$QEAV0@@Z) referenced in function main

1 个答案:

答案 0 :(得分:0)

当我使用Qtcreator构建项目时,我似乎也遇到了这个问题。但是当我使用vs2012打开“.pro”项目并构建它时。这个错误会消失。也许你可以尝试这种方法。