Click here to Skip to main content
15,559,455 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
It have two header files in my library source , hence I include both
of them in my client code . The code and library compiles, however,
I get "unreferenced error " when I try to use the library.

What I have tried:

compare with a single reference library
Posted
Updated 29-May-21 8:09am
Comments
Richard MacCutchan 30-May-21 3:27am    
Without seeing some code and the exact error message, and the line it refers to, it is impossible to answer the question.

1 solution

This is probably a linking error. When you compile the client program, you need to tell the linker where to find the library. For linux that would be
gcc client.c -L<path/to/lib> -llib -o client
. You can find instructions for doing that for a VisualStudio project Here[^]

Your question asks "Can referencing the library with TWO includes cause problem?". The answer is "Maybe". If the include file has #include guards, then no, but otherwise, "Probably".
example #include file with guards
C
#ifndef MY_LIB_H
#define MY_LIB_H

struct s {
   int i;
    double d;
};    

int foo(struct s  *my_struct);

#endif
Without the include guards, the compiler should complain about multiple definitions of struct s, if the header file is included more than once.
 
Share this answer
 
Comments
Member 14968771 29-May-21 14:29pm    
To be honest , I do not see your point / reference to guards. I have added another level of include , with guard, and have a same issue.
My conclusions - the problem is NOT in library reference include point. AFter I find the problem I'll go back to multi library reference points, just to make sure .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900