linker error

answerme's Avatar, Join Date: Dec 2007
Ambitious contributor
I have added two files on my existing mfc application a1.h &a1.cpp . I have function defintion in a1.cpp to read serially. This function iam calling in Scgenview::Ontimer() function in a thread . Below is the code
Code:
a1.h 
int readserial();
Code:
a1.cpp
#include "stdafx.h"
#include"a1.h"
readserial()
{
function defintion
}
Code:
Scgenview.cpp
#include"a1.h"
#include "stdafx.h"
void CScenGenView::OnTimer(UINT_PTR nIDEvent)
{

	LPVOID param= NULL;
	HANDLE GPS_READ = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)readserial(),(LPVOID) param, 0,NULL);
	
}

But i am getting a linker error which is listed below
Code:
Error	41	fatal error LNK1120: 1 unresolved externals	Debug\ScenGen.exe	ScenGen


Error	40	error LNK2019: unresolved external symbol "int __cdecl readserial(void)" (?readserial@@YAHXZ) referenced in function "public: void __thiscall CScenGenView::OnTimer(unsigned int)" (?OnTimer@CScenGenView@@QAEXI@Z)	ScenGenView.obj	ScenGen
0
Gene Poole's Avatar, Join Date: Nov 2009
Contributor
I don't know about the first error.

Your second error is because the function signature for the thread proc is wrong. You need to declare readserial() like this:

Code:
DWORD WINAPI readserial(LPVOID lpParameter);