Thread: Weird String error (LNK2019)

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    41

    Weird String error (LNK2019)

    Well, I've been working on a simple explorer.exe replacement, with it's own simple scripting language.

    Everything was going fine until I added a ParseScript, and tokenizeString Function:
    Code:
    PUNCH error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl punch::tokenizeString(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> >)" (?tokenizeString@punch@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@V?$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 "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl punchScript::ParseScript(class punchScript::scriptObject)" (?ParseScript@punchScript@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VscriptObject@1@@Z)
    Now, from what I can gather, the error is related to the ParseScript function. Here's that and the tokenizeString one (Based on the one from the FAQ):

    ParseScript:
    Code:
    string punchScript::ParseScript(scriptObject script)
    {
    	vector < string > commands;
    	punch::tokenizeString(script.commands, commands,  "\n");
    	
    	for(int i=0; i < (int)commands.size(); i++)
    	{
    		if(commands[i].find("createWindow ", 0) == 0)
    		{
    			string file = commands[i].erase(0, 12); //File for that command
    			char* buff = "";
    			sprintf(buff, "%s", file.c_str());
    			ShellExecute(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
    		}
    		
    		if(commands[i].find("script ", 0) == 0)
    		{
    			string file = commands[i].erase(0, 6); //File for that command
    			
    			scriptObject obj = LoadScript(file);
    			return ParseScript(obj);
    		}
    	}
    	
    	return "TRUE";
    }
    tokenizeString:
    Code:
             string tokenizeString(string str1, vector<string> target, string delimeter="\n")
             {
    			  string str = str1;
    			  vector <string> tokens; //we'll put all of the tokens in here 
    			  string  temp;
    
    			  while (str.find(delimeter, 0) != string::npos)
    			  { 
    			    size_t  pos = str.find(delimeter, 0); //store the position of the delimiter
    			    temp = str.substr(0, pos);      //get the token
    			    str.erase(0, pos + 1);          //erase it from the source 
    			    tokens.push_back(temp);                //and put it into the array
    			  }
    
      			  tokens.push_back(str);           //the last token is all alone
    				
    			 target = tokens;
    			 return "TRUE";
    		}
    Sorry for the overly-long post

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    You didn't need to double post.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    41
    I double posted? :S

    I *Did* Have a browser crash almost as soon as I clicked "submit", but It didn't display on the page...

    *Shrugs* Could a mod please remove this topic, then?

  4. #4
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    Where is your class definition?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    41
    Code:
    class punchScript::scriptObject
    {
    	public:
    		string file; //Filename
    		string comments; //All the Comments, unused
    		
    		string commands; //List of commands and their parameters, separated by newline
    };
    I'll attach the other files as well..

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I wonder why you bother creating so many namespaces if then you simply throw them all away with the using directives. Might as well forget about namespaces. You will save yourself and anyone else an headache when looking at your code.

    Your problem is definitely related to this. std::string is not being seen inside the punch namespace. Fix it.

    (I bet you are going to place using namespace std inside punch)
    Last edited by Mario F.; 08-08-2006 at 08:29 AM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    The problem is that the linker cannot find the definition of punch::tokenizeString. This is because you didn't define it in the punch namespace. Add punch:: to the definition of tokenizeString.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  3. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM