Click here to Skip to main content
15,844,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
// mainfrm.h
enum
{		
    logAll = 0xff
};
void Log(int nIdx, LPCTSTR lpText, int nType = logAll, LPCTSTR lpDeviceName = NULL);
//SesLog.h
int m_nDeviceID;
CString m_strDeviceName;
// SesLog.cpp
#include "Mainfrm.h"
#include "SesLog.h"
void CSessionLog::Log(LPCSTR lpText)
{
	if(m_pParent)
		m_pParent->Log(m_nDeviceID, lpText, logAll, m_strDeviceName);


error LNK2019: unresolved external symbol "public: void __thiscall CMainFrame::Log(int,char const *,int,char const *)" (?Log@CMainFrame@@QAEXHPBDH0@Z) referenced in function "public: void __thiscall CSessionLog::Log(char const *)" (?Log@CSessionLog@@QAEXPBD@Z) \SesLog.obj

VS 2010
Help would be appreciated.

Thanks
Posted

The linker couldn't find the Log function declared in class CMainFrame.

You did this declaration in MainFrm.h:
C++
void Log(int arg1, char const * arg2, int arg3, char const * arg4);

But you didn't write the implementation for this function anywhere. Check your MainFrm.cpp file and make sure you didn't forget or maybe commented it:
C++
//this function implementation doesn't exist.
//did you comment it?
void CMainFrame::Log(int arg1, char const * arg2, int arg3, char const * arg4)
{
    ....
}


By the way, I suppose you want to declare you char pointers parameters as const char* and not char const*...
 
Share this answer
 
v2
Comments
Albert Holguin 13-May-11 11:30am    
I guess if it was a lib you wouldn't have a function declaration in your own code, my 5... :)
Olivier Levrey 13-May-11 11:46am    
Thank you Albert. It is often tricky to solve linker issues, especially for beginners. I think OP will have some more problems: have a look to his last comment.
Albert Holguin 13-May-11 11:35am    
Just noticed he has this m_pParent->Log but the Log prototype doesn't look like part of a class (at least he didn't show it as included in a class)
Member 4581741 13-May-11 11:39am    
Ok i figured out that the header file MainFrm.h is coming from ..\rhub\mainfrm.h.
& in that rhub directory too it has Mainfrm.cpp which has Log function.

Now what do i need to do to call the function from that .cpp?
Should i add that cpp in my project ?

Advice
Thanks
Olivier Levrey 13-May-11 11:43am    
Yes, you need the .cpp file. But it sounds strange. Do you mean you are using MainFrm.cpp from another project?? In that case, I predict a lot of errors coming...
Maybe you don't include the corresponding header file.
 
Share this answer
 
Comments
CPallini 16-May-11 5:07am    
Nope: that's a linker error, not a compiler one.

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