|
I am creating a class as follows...
extern"C" class Logger
{ public:
string message;
void logMIN(string message);
void logMID(string message);
void logMAX(string message);
};
extern "C"
void Logger::logMIN(string message)
{
.....
}
extern"C"
void Logger::logMID(string message)
{
.....
}
extern"C"
void Logger::logMAX(string message)
{
......
}
I call these functions from main. Following is the error that I get on building... Please help me resolve this
Logger.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl log(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >) " (?l
og@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z)
...THANKS </char></char,struct></char></char,struct>
|
|
|
|
|
I just reported your message for posting the same thing over and over. You were given answers when you asked this question yesterday.
See here and here
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
yes but it was not resolved..
|
|
|
|
|
If it was not resolved, it could be only because you did not give sufficient information at first, and then you did not care to reply to the ones who posted to you. You could have replied to them, explaining what you tried and what was the outcome.
Is it hard to understand that if you post the same thing again, you will get the very same reply?
Also, I find it very difficult to understand things like "it is not working", "it was not resolved", etc.,
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
It was either Benjamin Franklin or Albert Einstein that defined insanity as doing the same thing over and over again and expecting different results.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I agree with Rajesh you should have followed the queries for your previous post instead of reposting it.
It seems you are missing the definition for a function whose prototype is something like,
string log(string);
and not related to the code you shown about the Logger class.
BTW, use <pre></pre> and format the message correctly when posting such messages.
|
|
|
|
|
I am sorry for doing that.
I have also included the function string log(string) but still that error persists.
|
|
|
|
|
pl_kode wrote: I have also included the function string log(string) but still that error persists.
how, where, and post full length error which shows "referenced in function _xxx".
|
|
|
|
|
I have done like this..
extern string log(string);
extern"C"
void Logger::logMIN(string message)
{
log(message);
}
error is...
Linking...
Logger.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > __cdecl log(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > ) " (?l
og@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@Z)
Debug/test_dll_log.exe : fatal error LNK1120: 1 unresolved externals
</char></char,struct></char></char,struct>
|
|
|
|
|
pl_kode wrote: extern string log(string);
this is the declaration, where the definition? i Hope you know the meaning of function definition. I don't know such a prototyped function in SDK, if you know link with corresponding library.
|
|
|
|
|
The definition of log(message) is in another file in the same project. In which I print this message...
Goes like..
log(string message)
{
cout<<message;
}
the above function is called like what I had given earlier. This function is defined outside the Logger class.
|
|
|
|
|
your function prototype doesnot match with the definition, since these are in different compilation unit and the compilation unit where you defined the function doesnot aware of the faulty declaration, compiler didn't shown error,
you need ti change like this,
string log(string message)
{
cout << message;
return message;
}
or change the prototype as
extern void log(string message);
and define as
void log (string message)
{
cout << message;
}
|
|
|
|
|
Thanks a lot it worked.. Thank you for your time.
|
|
|
|
|
and you can go for pass - by - reference.
|
|
|
|
|
hai,
i have written a code to created a status bar and i get the following error while i run the project,what's wrong with the code???
"Unhandled exception at 0x7837b7a8 (mfc80ud.dll) in kk.exe: 0xC0000005: Access violation writing location 0x00000014."
and the error is shown here:
void CStatusBar::SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth)
{
ASSERT_VALID(this);
BOOL bChanged = FALSE;
AFX_STATUSPANE* pSBP = _GetPanePtr(nIndex);
error-------->pSBP->nID = nID;
if (pSBP->nStyle != nStyle)
{
if ((pSBP->nStyle ^ nStyle) & SBPS_STRETCH)
bChanged = TRUE;
else
{
pSBP->nStyle = nStyle;
pSBP->nFlags |= SBPF_UPDATE;
SetPaneText(nIndex, pSBP->strText);
}
pSBP->nStyle = nStyle;
}
and my coding is
m_bar.Create(this);
CRect rect;
GetClientRect(&rect);
m_bar.SetPaneInfo(1,scan,SBPS_STRETCH ,0);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,
scan);
CString s;
s="scan";
m_bar.SetPaneText(0,s);
Raja
|
|
|
|
|
AFAIK panes are 0 indexed so if you only have one pane in your status bar, then your code will crash.
|
|
|
|
|
Hi,
I got XOffice source from net but when I create a print preview of any document it directily sends print command to printer. Can anyone tell us how to avoid this.
Another problem is with excel where this code does not provide "Freez Panes" in Window menu. This option is not available at all. How to include such functionality.
This architecture is based on OLE.
Any input will help.
Thanks
SNI
jhghjghj
|
|
|
|
|
on a single click how do i take a snapshot and print of currently displayed screen using VC++/MFC
|
|
|
|
|
There are lot of articles in the code project about capturing screen. Why dont you have a search?
|
|
|
|
|
|
See here.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have a MFC class which is derived from CWinApp. It has got two methods set and get. I have to use this set method in a Win32 lib. But when I include the header file of above MFC application. I am getting a compilation error like
C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> . Can I know how to solve this problem.
Thanks & Regards
|
|
|
|
|
what about using a wrapper function which doesnot include MFC headers in its declaration to get and set properties with CWinApp based class.
|
|
|
|
|
I use FILE to read datas from file.But it does not read full datas.
For Ex: if my file have 9 datas it reads only 6 datas then it jumped out from the loop.
when i see the YCS file.. it contains 9 datas, so no problem in writing.
Problem only in reading data. THis is my code...Whats the problem???Pls help me.
void ReadThermodata()
{
char FPath[] = "C:\\SelCompLst.YCS";
FILE *fp;
SThermoData pData;
if((fp = fopen((LPCTSTR)FPath,"r"))==NULL)
{
return;
}
int cnt = 0;
while( fread( &pData, sizeof( struct SThermoData ), 1 ,fp ) )
{
ThermoDataList.push_back(pData);
cnt = cnt + 1;
}
}
Anu
|
|
|
|