Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   linker error (http://www.go4expert.com/forums/linker-error-t21291/)

answerme 11Mar2010 10:42

linker error
 
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


Gene Poole 12Mar2010 00:01

Re: linker error
 
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);


All times are GMT +5.5. The time now is 20:38.