1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

linker error

Discussion in 'Win32' started by answerme, Mar 11, 2010.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    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:
    [B]a1.h [/B]
    int readserial();
    Code:
    [B]a1.cpp[/B]
    #include "stdafx.h"
    #include"a1.h"
    readserial()
    {
    function defintion
    }
    
    Code:
    [B]Scgenview.cpp[/B]
    #include"a1.h"
    #include "stdafx.h"
    void CScenGenView::OnTimer(UINT_PTR nIDEvent)
    {
    
    	LPVOID param= NULL;
    	HANDLE GPS_READ = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)[B]readserial[/B](),(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
     
  2. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    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);
    
     

Share This Page