need help interpreting error message

Jan 1, 2019 at 4:56pm
Microsoft must have held an internal contest to see how difficult they could make an error message to decipher.

I'm getting this message, and it's not helpful. I can't tell exactly what item is the problem, and I did a few things before I compiled, and it's not highlighting the culprit by jumping to the line. I added line breaks to make this fit on the page. Not sure if I broke it in the right places.

The error message disappears when I comment out the call to words_to_vector in the constructor. However, I made not changes to that particular routine. I did mess around with some structure or variable references, but can't tune down to what exact change I made.

Any help appreciated. Thanks.

Severity Code Description Project File Line Suppression State
Error LNK2019

unresolved external symbol "private: bool __thiscall AddressCls::words_to_vector(class std::basic_string
<char,struct std::char_traits<char>,
class std::allocator<char> >,
class std::vector<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> >,
class std::allocator<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> > > > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"

(?words_to_vector@AddressCls@@AAE_NV?
$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@AAV?$vector@V
?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@V?$allocator@V
?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@2@@3@0@Z)
referenced in function "public: __thiscall AddressCls::AddressCls(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"
(??0AddressCls@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) Address_Matcher_Classes C:\Users\DSNoS\source\repos\Address_Matcher_Classes\Address_Matcher_Classes\AddressCls.obj 1


here is my .h contents
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <vector>
#include <string>

using namespace std;

class AddressCls
{
public:
	AddressCls();
	AddressCls(string);

	~AddressCls();
	int get_word_beg();
	int get_word_end();

private:
	int word_beg;
	int word_end;
	int words_size;
	vector<string> words;

	struct address_struct {
		int codex;
		bool address_status;  // true = address parsible. false = address unparsable.
		bool street_yn;
		string street_num;
		int street_num_status; // -1 = unchecked, 0 = checked and empty, 1 = checked and filled

	};

	string pop_first_word(string &, const string);
	bool words_to_vector(string, vector <string> &, string);
	

};




here is my .cpp code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "pch.h"
#include "AddressCls.h"


AddressCls::AddressCls(string instring)
{
	words.clear();
	words_to_vector(instring,words," ");
	word_beg = 0;
	word_end = words.size() - 1;
	address_struct address = {};
}
	// get word_beg
	
	// increment word_beg
	// decrement word_end
	// populate words vector

string pop_first_word(string &remaining_address, const string delim) {


	int position = remaining_address.find(delim);

	string first_word = remaining_address.substr(0, position);
	remaining_address = remaining_address.substr(position + 1);

	return first_word;
}
bool words_to_vector(string instring, vector <string> &words, string delim) {
	//parse on delimiter and store into vector
	string thisword;
	int start = 0;
	int pos = instring.find(delim, 0);
	while (-1 < pos) {
		thisword = pop_first_word(instring, delim);
		start = instring.find(delim, start);
		if (thisword != "") {
			words.push_back(thisword);
		}
		pos = instring.find(delim, 0);
		//get last one

	}
	if ((pos == -1) && (instring != "")) {
		words.push_back(instring);
	}

	return true;
}
	




AddressCls::~AddressCls()
{
}


Last edited on Jan 1, 2019 at 5:36pm
Jan 1, 2019 at 5:12pm
The linker is saying you haven't defined those member functions because you forgot to put AddressCls:: in front of the names in the source file.
Jan 1, 2019 at 5:16pm
> unresolved external symbol
This is a linker message, not a compiler message.
Unresolved symbols usually amount to one of the following
- forgetting to implement a function.
- forgetting class/namespace resolution (as you've done)
- simply mis-spelling the name of a symbol somewhere.




Line 19 should be
string AddressCls::pop_first_word(string &remaining_address, const string delim)

Line 29 should be
bool AddressCls::words_to_vector(string instring, vector <string> &words, string delim)
Jan 1, 2019 at 5:30pm
I would question why you have member functions that don't use the state of the object at all.
Jan 1, 2019 at 5:41pm
Ah, got it. Thanks for your help, salem c.
Last edited on Jan 1, 2019 at 6:11pm
Topic archived. No new replies allowed.