•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,556 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,664 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 1419 | Replies: 4 | Solved
![]() |
•
•
Join Date: Oct 2006
Location: Manchester, UK
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hello to you all,
I am having problems with some code that I am working on for a text parsing system from an external *.txt file. The problem seems to stem from the Tokenize function, as I get a:
"LNK2019 error: unresolved external symbol "void __cdecl Tokenize(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,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> > > > &)"
Thank you very much in advance,
Delphi
I am having problems with some code that I am working on for a text parsing system from an external *.txt file. The problem seems to stem from the Tokenize function, as I get a:
"LNK2019 error: unresolved external symbol "void __cdecl Tokenize(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,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> > > > &)"
cplusplus Syntax (Toggle Plain Text)
// stringtest.cpp #include <string> #include <algorithm> #include <vector> #include <iostream> #include <fstream> using namespace std; void Tokenize(const string& str, vector<string>& tokens); int main() { vector<string> tokens; char _string[256]; char inputChar[256]; string inputString; ifstream input; cout << "Enter name of an existing file: "; cin.get( _string, 256 ); input.open( _string ); input.getline( inputChar, 256 ); cout << inputChar << endl; inputString = inputChar; cout << inputString << endl << endl; Tokenize( inputString, token ); copy( tokens.begin(), tokens.end(), ostream_iterator<string>(cout, ", ")); return 0; } void Tokenize( const string& str, vector<string>& tokens, const string& delimiters = "|") { // Tokenize taken from [url]http://www.hispafuentes.com/[/url] // Skip delimiters at the beginning string::size_type lastPos = str.find_first_not_of( delimeters, 0 ); // Find first "non-delimiter". string::size_type pos = str.find_first_of( delimiters, lastPos ); while (string::npos != pos || string::npos != lastPos) { // Found a token add it to the vector tokens.push_back( str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of( delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of( delimiters, lastPos ); } }
Thank you very much in advance,
Delphi
Last edited by delphi_uk : Mar 15th, 2007 at 6:50 pm.
How in the world did you get it to compile? For one thing, you'll need to #include <iterator> if you intend on using
ostream_iterator. cplusplus Syntax (Toggle Plain Text)
int main() { vector<string> tokens; char _string[256]; char inputChar[256]; string inputString; ifstream input; cout << "Enter name of an existing file: "; cin.get( _string, 256 ); input.open( _string ); input.getline( inputChar, 256 ); cout << inputChar << endl; inputString = inputChar; cout << inputString << endl << endl; Tokenize( inputString, token ); // add an 's' to 'token'
cplusplus Syntax (Toggle Plain Text)
void Tokenize( const string& str, vector<string>& tokens, const string& delimiters = "|") { // Tokenize taken from [url]http://www.hispafuentes.com/[/url] // Skip delimiters at the beginning string::size_type lastPos = str.find_first_not_of( delimeters, 0 ); // you're spelling 'delimiters' wrong
tuxation.com - Linux articles, tutorials, and discussions
•
•
Join Date: Oct 2006
Location: Manchester, UK
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
How in the world did you get it to compile? For one thing, you'll need to #include <iterator> if you intend on using ostream_iterator. I didnt manage to get it compile thats why I was getting the error. Thanks for the advice on the iterator, the site that I took the code snippet from did not have that header in the sample code.
•
•
•
•
cplusplus Syntax (Toggle Plain Text)
Tokenize( inputString, token ); // add an 's' to 'token'
My appologies on the spelling mistake, that was human error as I copied the code from my laptop to the desktop, in the original program this was correct.
•
•
•
•
cplusplus Syntax (Toggle Plain Text)
void Tokenize( const string& str, vector<string>& tokens, const string& delimiters = "|") { // Tokenize taken from [url]http://www.hispafuentes.com/[/url] // Skip delimiters at the beginning string::size_type lastPos = str.find_first_not_of( delimeters, 0 ); // you're spelling 'delimiters' wrong
Again this is due to inaccuracies in copying the program.
However non of these issues that were brought up solved the issue of the LNK2019 error.
Also thank you very much for the fast response, I have lurked on these forums and used some solutions for quite some time, however this is the first time I have needed to ask a question.
Delphi
Last edited by delphi_uk : Mar 15th, 2007 at 7:15 pm.
Another note: you should place your default parameter thingy in the function prototype instead of the actual function implementation. This is likely what's causing the linker errors.
[edit]
The actual reason for the linker errors is this:
You never included the third parameter, delimiters. No wonder the linker choked up.
[edit]
The actual reason for the linker errors is this:
cplusplus Syntax (Toggle Plain Text)
void Tokenize(const string& str, vector<string>& tokens);
Last edited by John A : Mar 15th, 2007 at 7:32 pm.
tuxation.com - Linux articles, tutorials, and discussions
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
- unresolved external symbol error (C++)
- Need help with "error LNK2001 unresolved external symbol" (C++)
- error LNK2001: unresolved external symbol (C++)
- error LNK2001: unresolved external symbol (C++)
- error LNK2001: unresolved external symbol (C++)
- unresolved external symbol when using a hashtable class (C++)
- error LNK2001: unresolved external symbol (C++)
Other Threads in the C++ Forum
- Previous Thread: help me......
- Next Thread: To fetch data through command line arguments



Linear Mode