0

Details:
I am trying to call a function defined in a .c file from a member function in .cpp file. But I am getting linking error as unresolved external symbol.
below are the details:

I am using Microsoft Visual Studio 2010. In my solution I have created 3 projects. Lets say Project1,Project2 & Project3. Out of this Project 2 & 3 are of Configuration type (Static library (.lib) ) and Project1 is of Configuration type Dynamic Library (.dll).

In Project2 I have foo.c file in which I have defined a function return_type foo(args) and I have declared it in foo.h file.

In Project1 I have foo.cpp file in which I have class with name cFooClass which has one of the member function as cFooMemberFunction. I am calling foo(c Function) from this member function. For this I have added Project2.lib and Project3.lib libraries in the dependencies of Project1 and I have included foo.h file(with extern "C") in foo.cpp. But still I am getting error as unresolved external symbol.

Can anyone help me with this?

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91
RohanA
  • 1
  • 1
  • Possible duplicate of [Combining C++ and C - how does #ifdef \_\_cplusplus work?](http://stackoverflow.com/questions/3789340/combining-c-and-c-how-does-ifdef-cplusplus-work) – VolkerK Apr 19 '16 at 05:46
  • Sounds like either you've failed at using extern "C" to me, or there's an important detail you haven't listed. Try stripping down your source files to the bare minimum in an empty sln. – zeromus Apr 19 '16 at 08:38
  • @zeromus, I have tried using extern "C" in 2 ways. 1st: In foo.h I enclosed the function declaration in extern "C".(with guards #ifdef __cplusplus) and then included this foo.h in foo.cpp file. 2nd: No change in foo.h file, instead I included foo.h in foo.cpp enclosed within extern "C". – RohanA Apr 19 '16 at 09:10

0 Answers0