好了,我有我的代码中的一个问题试图找出问题。我有很多的代码,所以我只打算张贴被搞乱了,当我编译的相关部分。我有一个类的以下函数内部它将编译一切都将运行良好,直到我调用函数“CalculateProbabilityResults”,它运行在它的代码七号线。我“去评论说:”这行代码在我的程序,所以你可以更容易找到它。我敢肯定,我需要合适的#include指令,因为它编译罚款时,不调用该函数,所以不能成为问题可以吗?我知道我的一些命名符号的需要一点帮助,所以请多多包涵。预先感谢帮助家伙。

int SQLServer::CalculateProbabilityResults(int profile, int frame, int time_period, int TimeWindowSize) {
    ofstream ResultFile;
    stringstream searchFileName;
    stringstream outputName;
    vector<vector<int>> timeFrameItemsets;
    int num = getTimeFrameFile(frame*TimeWindowSize, TimeWindowSize);
    cout << num << endl;

    //outputName << "Results" << getTimeFrameFile((frame*TimeWindowSize), TimeWindowSize) << ".csv";
    cout << outputName.str() << endl;
    outputName.clear();
    //ResultFile.open(outputName.str().c_str());
    ResultFile.close();
    result.resize(0);
    return 0;
}

int getTimeFrameFile(int timeInHours, int timeFrameSize) {
    int fileNum = 0;
    int testWin;
    if (timeInHours > 24) {
        while (timeInHours >24)
            timeInHours -= 24;
    }
    for (testWin = 0; testWin < 24/timeFrameSize; testWin++) {
        if (timeInHours >= testWin*timeFrameSize && timeInHours < (testWin+1)*timeFrameSize)
            fileNum = testWin+1;
    }
    if (fileNum == 0)
        fileNum = testWin+1;
    return fileNum;
}

呼叫日志

1>------ Rebuild All started: Project: MobileSPADE_1.3, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'MobileSPADE_1.3', configuration 'Debug|Win32'
1>Compiling...
1>main.cpp
1>MobileSPADE.cpp
1>SQLServer.cpp
1>Generating Code...
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>LINK : C:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\Debug\MobileSPADE_1.3.exe not found or not built by the last incremental link; performing full link
1>SQLServer.obj : error LNK2019: unresolved external symbol "public: int __thiscall SQLServer::getTimeFrameFile(int,int)" (?getTimeFrameFile@SQLServer@@QAEHHH@Z) referenced in function "public: int __thiscall SQLServer::CalculateProbabilityResults(int,int,int,int)" (?CalculateProbabilityResults@SQLServer@@QAEHHHHH@Z)
1>C:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\Debug\MobileSPADE_1.3.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\MobileSPADE_1.3\Debug\BuildLog.htm"
1>MobileSPADE_1.3 - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
有帮助吗?

解决方案

编译器认为是getTimeFrameFile一个SQLServer方法:

  

解析外部符号 “公共:INT __thiscall的 SQLServer的 :: getTimeFrameFile(INT,INT)”

但你有它定义为一个自由功能:

int getTimeFrameFile(int timeInHours, int timeFrameSize) {

更改,其从自由功能的一类方法将解决这个问题:

int SQLServer::getTimeFrameFile(int timeInHours, int timeFrameSize)

其他提示

把功能getTimeFrameFile上述SQLServer::CalculateProbabilityResults

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top