Click here to Skip to main content
16,012,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi and good morning to all the user of code project,
i try to link my thread from other cpp file to the main cpp, but it show an error message, as show as below,

VB
>AutoModeDlg.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl MyThreadA(void *)" (?MyThreadA@@YAIPAX@Z) referenced in function "public: void __thiscall CAutoModeDlg::OnBnClickedButton3(void)" (?OnBnClickedButton3@CAutoModeDlg@@QAEXXZ)
1>AutoModeDlg.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl MyThreadB(void *)" (?MyThreadB@@YAIPAX@Z) referenced in function "public: void __thiscall CAutoModeDlg::OnBnClickedButton4(void)" (?OnBnClickedButton4@CAutoModeDlg@@QAEXXZ)
1>C:\Users\Noldx\documents\visual studio 2010\Projects\2NDTASK\Debug\2NDTASK.exe : fatal error LNK1120: 2 unresolved externals



here is the part of the sample code

in my secondary .cpp file
2ndary.h
C++
static UINT MyThreadA(LPVOID pParam);
int a();

2ndary .cpp
C++
int C2ndary::a()
{
//command of thread
return 0;
}

main cpp's header
C++
CWinThread* thread1;

main cpp
C++
#include "2ndary.h"

extern UINT MyThreadA(LPVOID pParam);//call back the static UINT MyThreadA(LPVOID //pParam) that i declared in the 2ndary.h


// bla bla bla

UINT C2ndary::MyThreadA(LPVOID pParam)
{
C2ndary* dialog;
dialog=(C2ndary*)pParam;
dialog->a();
return 1;
}

void CMaindlg::OnClickedButton1()
{
thread1=AfxBeginThread(MyThreadA,this);
}


thanks,

rgds

illm1995
Posted
Updated 1-Oct-12 19:38pm
v6
Comments
JOHN 602 2-Oct-12 16:45pm    
Hey bro
I be quite honest with you didn't go into the heart of you code. But as I know one of the proved method to communicate between the processes - using Pipes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900