0

スタックオーバーフロー、

LNK2019 エラーを解決しようとしましたが、成功しませんでした。ここで同様の投稿をいくつか見たので、この問題に適切なプロセスを与え、他の投稿を読みました (そして自分で解決しようとしました)。私の理解に根本的な問題があるかもしれませんので、助けていただければ幸いです。私は最近、python から C++ に切り替えました。

私が学んだことは、このエラーは多くの場合、異なるライブラリからコンパイルすることによって引き起こされるということでしたが、これがどのように私に当てはまるのかはわかりません. 問題があれば、私は Stanford C++ ライブラリを使用しています。VC++ 2008 を使用しています。

#include <iostream>
#include "lexicon.h"
#include "queue.h"
#include "simpio.h"
#include "vector.h"
#include "console.h"

using namespace std;
void findchoices(string &startword, string &endword);


int main(Lexicon &choices) {
    string startword = getLine("Enter start word (RETURN to quit): ");
    string endword = getLine("Enter end word (RETURN to quit): ");

    if (startword == "") return 0;
    if (endword == "") return 0;

    //cout<< startword << " " << endword << endl;

    findchoices(startword, endword);

    //foreach (string j in choices) {
    //  cout << j << endl;
    //}

    return 0;
}

void findchoices(string &startword, string &endword) {
    Lexicon english("EnglishWords.dat");
    Lexicon choices;

    foreach (string i in english) {if (i.length() == startword.size()) choices.add(i);}
    foreach (string i in choices) {cout<<i<<endl;}

}

それでおしまい。

エラー:

1>StanfordCPPLib.lib(main.obj) : error LNK2019: unresolved external symbol "int __cdecl Main(void)" (?Main@@YAHXZ) referenced in function "int __cdecl Main(int,char * *)" (?Main@@YAHHPAPAD@Z)
1>G:\assign2-wordladder-randomwriter-PC\WordLadder\Debug\WordLadder.exe : fatal error LNK1120: 1 unresolved externals
4

1 に答える 1

2

と定義mainした理由はint main(Lexicon &choices)?次のように変更します。

int main() {
    //...
}
于 2013-03-08T00:51:20.240 に答える