Reputation: 4830
I have successfully added a dynamic library to a program, but when I try to include the header file in a second file of the project I get errors about class redeclaration. I will add more info if this isn't enough
Upvotes: 0
Views: 619
Reputation: 15969
An #include will replace the #include statement with the files content; having multiple #include's of the same file will therefore redefine the elements multiple times. The typical way is a safeguard like:
/* file foo .h */
#ifndef _FOO_H
#define _FOO_H
/* content */
#endif
Upvotes: 4
Reputation: 9620
You need to put guards into your header so it isn't included multiple times. For file 'my.h', you can add something along the lines of:
#ifndef MY_H
#define MY_H
// Header declarations here
#endif
This way, you can include the .h file multiple times but it will only be included the first time.
Upvotes: 5