1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

linker error

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

  1. answerme

    answerme New Member

    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

    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