Problem with DLL
-
Hi, We have create a C++ DLL. While creating this DLL we have included "string.h" "vector.h" etc and so on... We are able to compile and able to use exported functions in sample program with out any error. We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this? -Nandu
-
Hi, We have create a C++ DLL. While creating this DLL we have included "string.h" "vector.h" etc and so on... We are able to compile and able to use exported functions in sample program with out any error. We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this? -Nandu
Nandu_77b wrote:
We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this?
Yes. Before distributing your DLL,lib and H files to "him", test them in your own project before you distribute them.
led mike
-
Hi, We have create a C++ DLL. While creating this DLL we have included "string.h" "vector.h" etc and so on... We are able to compile and able to use exported functions in sample program with out any error. We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this? -Nandu
probably because he is including your header several times, and because your header is not robust. have you set an exclusive inclusion system in it (like the following) ?
#pragma once //depending on the compiler. not all support this
//your header body here...
#ifndef __HEADER_H_INCLUDED__
#define __HEADER_H_INCLUDED__//your header body here...
#endif
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
Nandu_77b wrote:
We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this?
Yes. Before distributing your DLL,lib and H files to "him", test them in your own project before you distribute them.
led mike
:confused: first debugging, now testing. What will you ask for next, documentation?
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
:confused: first debugging, now testing. What will you ask for next, documentation?
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, We have create a C++ DLL. While creating this DLL we have included "string.h" "vector.h" etc and so on... We are able to compile and able to use exported functions in sample program with out any error. We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines. Is there any way to avoide this? -Nandu
Nandu_77b wrote:
We have distributed our DLL with .lib and .h files. He reports that when he includes our .h file in his program, it is not compiling (compile or link errors). He is tell this is boz because it has multiply defines.
Please post the exact (full) error message because otherwise we will need to guess...
Cédric Moonen Software developer
Charting control [v1.4] OpenGL game tutorial in C++ -
probably because he is including your header several times, and because your header is not robust. have you set an exclusive inclusion system in it (like the following) ?
#pragma once //depending on the compiler. not all support this
//your header body here...
#ifndef __HEADER_H_INCLUDED__
#define __HEADER_H_INCLUDED__//your header body here...
#endif
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
Hi, Thanks Toxcct, Do i Need to add the below in my header file //header.h #ifndef __HEADER_H_INCLUDED__ #define __HEADER_H_INCLUDED__ //your header body here... #endif OR Who is going to use the DLL should include my header as below? #ifndef __HEADER_H_INCLUDED__ #define __HEADER_H_INCLUDED__ header.h #endif Which is the correct and best approach? -Nandu
-
probably because he is including your header several times, and because your header is not robust. have you set an exclusive inclusion system in it (like the following) ?
#pragma once //depending on the compiler. not all support this
//your header body here...
#ifndef __HEADER_H_INCLUDED__
#define __HEADER_H_INCLUDED__//your header body here...
#endif
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
TOx back after long time.. great!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
-
Hi, Thanks Toxcct, Do i Need to add the below in my header file //header.h #ifndef __HEADER_H_INCLUDED__ #define __HEADER_H_INCLUDED__ //your header body here... #endif OR Who is going to use the DLL should include my header as below? #ifndef __HEADER_H_INCLUDED__ #define __HEADER_H_INCLUDED__ header.h #endif Which is the correct and best approach? -Nandu
yes, you put the #ifndef construction in your own header. now, each time the file is included, this stuff prevents the header content to be actually included more than once. check this:
yourheader.h
src1.h:
#include "yourheader.h"
//...
src1.cpp:
#include "src1.h"
#include "yourheader.h"
//...do you see what happens in src1.cpp ? the user is including his own header (
src1.h
), and your header (yourheader.h
). but the problem is that in src1.cpp, when includingyourheader.h
, it is already included (bysrc1.h
), thus the "already defined identifier" error. so by putting such a code in your own header, you prevent such an error to occur; if the header is #included several times in the same compilation unit, only the first inclusion will be taken in account...[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
TOx back after long time.. great!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/xml>
;) holidays my friend
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
yes, you put the #ifndef construction in your own header. now, each time the file is included, this stuff prevents the header content to be actually included more than once. check this:
yourheader.h
src1.h:
#include "yourheader.h"
//...
src1.cpp:
#include "src1.h"
#include "yourheader.h"
//...do you see what happens in src1.cpp ? the user is including his own header (
src1.h
), and your header (yourheader.h
). but the problem is that in src1.cpp, when includingyourheader.h
, it is already included (bysrc1.h
), thus the "already defined identifier" error. so by putting such a code in your own header, you prevent such an error to occur; if the header is #included several times in the same compilation unit, only the first inclusion will be taken in account...[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
The above eplaination gives me clear understanding, Thanks a lot. Just for my clarification, one can include yourheader.h file only in src1.h and no need to include it again in src1.cpp. IS this correct? -Nandu
yes of course, my example was a bit too fast, but it happens (and i believe that's what happened to you) when you include files that include files that include.... and you can't control exactly what's included anymore...
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]