Reputation: 617
stack overflow,
I have been trying to resolve my LNK2019 error with no success. I saw several similar posts on here so I gave this problem its due process and read the other posts (and tried to resolve it myself). There might be something fundamentally wrong with my understanding so I appreciate your willingness to help. I recently switched from python to C++, so excuse the n00bishness.
What I learned was that this error is often caused by compiling from different libraries - but I'm not sure how this could be the case for me. If it matters, I am using the Stanford C++ library. Using 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;}
}
That's it.
Errors:
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
Upvotes: 0
Views: 992
Reputation: 18443
Why you defined main
as int main(Lexicon &choices)
? Change it to:
int main() {
//...
}
Upvotes: 2