In 'comp.lang.c',
mo**********@hotmail.com (JackyMove) wrote:
<...> I have compiled a library
"lib.lib" successfully using a simulator compatable to VC++ on Windows
platform.
I trust you, but I'm curious. What kind of 'simulator' is able to compile a
library?
Then I try to build an executatble in another project with
including "lib.lib".
Ok.
However, it gives me the errors: symbol xxx is
defined multiple times in a.obj and b.obj in "lib.lib".
Is it true? If yes, it means that your project is using source files that was
are already used to build the library, or that you define public names
already used by the library.
It seems that
there exists conflicts as I include some common ".h" file in both
source codes of the executable and the library. I would like to ask if
anyone know how to solve the problem.
It's hard to say without a reduced-to-minimum example of your problem. Of
course your design must follow the usual rules :
- Public names are unique.
- Public functions calls are prototyped.
- The public prototypes are declared once and only once in a header.
- This header is include both in the implementation files and in the user
files.
- This header is guarded again multiple inclusions:
#ifndef H_XXX
#define H_XXX
/* xxx.h */
<...>
#endif /* guard */
Just a reminder: headers only contain:
- include of other headers
- public macros definitions
- public constant definitions
- public types definitions
- public functions prototypes
- public objects declarations
[C99]
- public inline function definitions
No object or function definition. Never.
(well, except inline in C99).
--
-ed-
em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ:
http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c :
http://www.isty-info.uvsq.fr/~rumeau/fclc/