multiple symbol defined

J

JackyMove

Dear all,

I have encount the following problem. I have compiled a library
"lib.lib" successfully using a simulator compatable to VC++ on Windows
platform. Then I try to build an executatble in another project with
including "lib.lib". However, it gives me the errors: symbol xxx is
defined multiple times in a.obj and b.obj in "lib.lib". 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.

Thank you very much.

Regards,
Jacky
 
E

Eric G.

JackyMove said:
Dear all,

I have encount the following problem. I have compiled a library
"lib.lib" successfully using a simulator compatable to VC++ on Windows
platform. Then I try to build an executatble in another project with
including "lib.lib". However, it gives me the errors: symbol xxx is
defined multiple times in a.obj and b.obj in "lib.lib". 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.

Unfortunately, I do not. However, I could recomend that you try asking
your question in a programming newsgroup related to your compiler or
platform - you would be far more likely to find someone there familar
with your specific setup then in here.
 
E

Emmanuel Delahaye

In said:
<...> 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).
 
B

bd

Dear all,

I have encount the following problem. I have compiled a library
"lib.lib" successfully using a simulator compatable to VC++ on Windows
platform. Then I try to build an executatble in another project with
including "lib.lib". However, it gives me the errors: symbol xxx is
defined multiple times in a.obj and b.obj in "lib.lib". 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.

Did you declare a variable without the extern keyword in one of those
headers? If so, add the extern, and put the old declaration in one of the
..c files.
 
J

JackyMove

Thanks for the help. In fact, I have carelessly included a ".c" file
instead of ".h" and, so to raise such problem.

Thank you.

Regards,
Jacky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top