|
Thanks buddies..
Now i got the difference between #include "stdafx.h" and #pragma hdrstop
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi all,
I have created a DLL and its header name is simple.h which contains a global variable multiplier n a function multipy. For testing this dll i created a dialog based application n #included simple.h in CheckTestDll.h.
This CheckTestDll.h is #included in CheckTestDllDlg.h in which i m using the structure defined in header file of DLL.
But when i compile this test application i get this error
error LNK2005: "long multiplier" (?multiplier@@3JA) already defined in CheckTestDll.obj
Can anyone help me.
Thanks in anticipation.
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: error LNK2005: "long multiplier" (?multiplier@@3JA) already defined in CheckTestDll.obj
Global variables are not recommended to host in header files.
Since the DLL is written by yourself. I suggest you to move that global variable(s) into a .CPP file of that DLL project.
Maxwell Chen
|
|
|
|
|
Cyber Friend wrote: a global variable multiplier
declare the variable as extern..
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
You have to enclose your header into preprocessor to avoir it being copied several times:
#ifndef YOURFILE
#define YOURFILE
...
...
#endif
Post your header file, the problem is perhaps also there because of your variable.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Did you see msdn maybe you need to add /FORCE
and whats in header file
whitesky
|
|
|
|
|
This will not work
nave
|
|
|
|
|
i had one problem like this and used this switch and it worked. of course if he shows header file its good
whitesky
|
|
|
|
|
Will u plz try a sample..
nave
|
|
|
|
|
many years ago
whitesky
|
|
|
|
|
|
im very young
whitesky
|
|
|
|
|
did you get my mail (many days ago)
whitesky
|
|
|
|
|
|
my mail for your site
whitesky
|
|
|
|
|
I think this problem will not be solved unless
1.) The variable is decleared in the cpp and decalared extern in the header
2>) Make the variable static
nave
|
|
|
|
|
maybe but if he shows header files is good
whitesky
|
|
|
|
|
I have done that but error now changed from LNK2005 to LNK2001 . I m using multiply() function as well from dll but error is only regarding the variable multiplier.
Now error turns to be:
Linking...
CheckTestDllDlg.obj : error LNK2001: unresolved external symbol "int multiplier" (?multiplier@@3HA)
Debug/CheckTestDll.exe : fatal error LNK1120: 1 unresolved externals
n this is dll header file
//////////////////////////////////////////// simple.h/////////////////
#include "String.h"
#include <afxwin.h> // MFC core and standard components
#ifndef SIMPLE_H
#define SIMPLE_H
long multiply(long no);
#endif
///////////////////////////////////////////////////////////////////////
this is cpp file of Dll
////////////////////////////////////////////simple.cpp ///////////////////////////////////
#include "stdio.h"
#include "simple.h"
static long multiplier=14L;
long multiply(long no)
{
long retval;
retval = no * multiplier;
st.Format("Reslt is %d",retval);
MessageBox(NULL,st,"I",MB_OK);
return retval;
}
///////////////////////////////////////////////////////////////////////
Cyber Friend
Cyber Friend
|
|
|
|
|
sorry i actually want to answer Cedric Moonen
nave
|
|
|
|
|
Naveen R wrote: sorry i actually want to answer Cedric Moonen
Always quote when you answer somebody. That will avoid such kind of confusion .
Yeah, I know that's why I was asking for more precisions to see how he declared his variable.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Declare the variable in your header file as extern and define it in one of your .cpp files of your dll.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
I have done that but error now changed from LNK2005 to LNK2001 . I m using multiply() function as well from dll but error is only regarding the variable multiplier.
Now error turns to be:
Linking...
CheckTestDllDlg.obj : error LNK2001: unresolved external symbol "int multiplier" (?multiplier@@3HA)
Debug/CheckTestDll.exe : fatal error LNK1120: 1 unresolved externals
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: Linking...
CheckTestDllDlg.obj : error LNK2001: unresolved external symbol "int multiplier" (?multiplier@@3HA)
Debug/CheckTestDll.exe : fatal error LNK1120: 1 unresolved externals
This is happening because you haven't declared it in the .cpp file...
for e.g.
in yourclass.h
extern UINT multiplier;
in yourclass.cpp or some other .cpp file that is in the project...
UINT multiplier = 0;
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Hi Thomas,
I have done that but error now changed from LNK2005 to LNK2001 . I m using multiply() function as well from dll but error is only regarding the variable multiplier.
Now error turns to be:
Linking...
CheckTestDllDlg.obj : error LNK2001: unresolved external symbol "int multiplier" (?multiplier@@3HA)
Debug/CheckTestDll.exe : fatal error LNK1120: 1 unresolved externals
n this is dll header file
//////////////////////////////////////////// simple.h/////////////////
#include "String.h"
#include // MFC core and standard components
#ifndef SIMPLE_H
#define SIMPLE_H
long multiply(long no);
#endif
///////////////////////////////////////////////////////////////////////
this is cpp file of Dll
////////////////////////////////////////////simple.cpp ///////////////////////////////////
#include "stdio.h"
#include "simple.h"
static long multiplier=14L;
long multiply(long no)
{
long retval;
retval = no * multiplier;
st.Format("Reslt is %d",retval);
MessageBox(NULL,st,"I",MB_OK);
return retval;
}
///////////////////////////////////////////////////////////////////////
n i m using this variable in other application first defining above the class header file like this
extern long multiplier;
n then in one of class function i m using this variable.
Cyber Friend
|
|
|
|
|
Whats the possibility to set some text to the memory and read the same text after a while but in the same process. If it is possible how can i accoplish this please explain me in detial.
I have tried with memset() and etc., but i couldnt see the desired output.
|
|
|
|