I have this tow errors ,how I can solve it.any ideas?

error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup MSVCRTD.lib AC


fatal error LNK1120: 1 unresolved externals Debug\AC.exe AC

Generally a linker error is caused by calling a function that you don't have an implementation for. The linker throws and error saying "you've called this function, and I know it's supposed to exist, but I can't find it."

I don't get involved in Win32 programs, but I do know that WinMain and tmain are common alternate names for main() in Win32 programs. It looks like you need a WinMain but your current program has a tmain() instead.

I think you better post some code so that we can see what's actually going on.

int main(int argc, char* argv[])
{

//Inter the text file  
  
	  cout<<"Enter text file name.\n";
      cin>>text;
	  inFile2.open(text.c_str());
       if ( !inFile2 )
        {
          cout<<"Unable to open file. Enter a different name: ";
	      inFile2.clear();
          cin >> text;
	      inFile2.open(text.c_str());
	   }

      char *T;
	  T = new char[10000];


//Read the file			

	  while(getline(inFile2, line))
		  { 		
			strcpy_s(T, 10000, line.c_str());
			
     
			
            //convert char* to unicode

            string search1 = T;
            const size_t newsize1 = 10000;
            size_t origsize = strlen(search1.c_str()) + 1;
            size_t convertedChars = 0;
            wchar_t wcstring1[newsize1];
            mbstowcs( wcstring1, search1.c_str(), newsize1); 
            
			//wcscat_s(wcstring1, L" (wchar_t *)");
			
            			
            wcout << wcstring1 << endl;
        


    // perform the search.
     


	  aDataFound=aTree.SearchAhoCorasikMultiple( wcstring1 );
	for (int iCount=0;
		 iCount<aDataFound.size();
		 ++iCount)
		 printf(" AC Match Found :    %S \n",aDataFound[iCount].sDataFound.c_str());

	  }
	return 0;


}

Is this the complete code? Where are the variable declarations?

ifstream  inFile1, inFile2;
      string pattern,text,line;

I deleted part of the code to be easy to read , the problem started in the code when I added this part

aDataFound=aTree.SearchAhoCorasikMultiple( wcstring1 );	

for (int iCount=0;		 iCount<aDataFound.size();		 ++iCount)		 printf(" AC Match Found :    %S \n",aDataFound[iCount].sDataFound.c_str));

when i move this part out of the while loop its working if I assigned the function in line 49 static data like L"asfasdgadgd"

How is aTree.SearchAhoCorasikMultiple() defined? Are you using wcstring1 correctly for the function's expected argument/parameter?

Most probably you have defined entry point in linker advance setting in visual studio 2008. Make sure there is no additional entry point.

the definition of the function is

CSuffixTrie::DataFoundVector CSuffixTrie::SearchAhoCorasikMultiple(const SearchString& rString)const
{
	//Our vector of data found
	DataFoundVector aVec;

	//The current string we match
	SearchString sMatchedString;

	//Our node position
	const Node* pNode;
	pNode=&m_aRoot;

	//Iterate the string
	for (int iCount=0;
		 iCount<rString.length();
		 ++iCount)
	{
		//Did we switch node already
		bool bSwitch;
		bSwitch=false;

		//Loop while we got something
		while (1)
		{
			//Look for the char
			SearchMap::const_iterator aIterator;
			aIterator=pNode->aMap.find(rString[iCount]);

			//Do we have it?
			if (aIterator==pNode->aMap.end())
				//No, check if we have failure node
				if (!pNode->pFailureNode)
				{
					//No failure node, start at root again
					pNode=&m_aRoot;

					//Reset search string
					sMatchedString=L"";

					//Did we do a switch?
					if (bSwitch)
						//We need to do this over
						--iCount;

					//Exit this loop
					break;
				}
				else
				{
					//What is the depth difference?
					unsigned short usDepth;
					usDepth=pNode->usDepth-pNode->pFailureNode->usDepth-1;

					//This is how many chars to remove
					sMatchedString=sMatchedString.substr(usDepth,sMatchedString.length()-usDepth);

					//Go to the failure node
					pNode=pNode->pFailureNode;

					//Set to switch
					bSwitch=true;
				}
			else
			{
				//Add the char
				sMatchedString+=rString[iCount];

				//Save the new node
				pNode=aIterator->second;

				//Exit the loop
				break;
			}
		}

		//Is this a final node?
		if (pNode->bFinal)
		{
			//We got our data
			DataFound aData;
			aData.iFoundPosition=iCount-sMatchedString.length()+1;
			aData.sDataFound=sMatchedString;

			//Insert it
			aVec.push_back(aData);

			//Go back
			iCount-=sMatchedString.length()-1;

			//Reset the data
			sMatchedString=L"";
		}
	}

	//Done
	return aVec;
}

Most probably you have defined entry point in linker advance setting in visual studio 2008. Make sure there is no additional entry point.

I checked it no entry point .................Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.