2

我在使用 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
4

1 回答 1

0

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

于 2013-08-09T03:10:08.600 回答