Search code examples
c++cinteropkeil

Adding a library in Keil as a facade to use C++ inside C project


Because I wanna use some C++ library that I wrote inside my C project I found the facade pattern as a solution for that in another question asked on SO.

I compiled my project containing calculateSensors.h/cpp and facade.h/cpp as a library and included it into my main project. It's just doing some rand function and returning it from a cpp class to test whether this approach is working.

Now the problem is that after including the library I'm not sure how to include and call my functions. I just tried to include facade.h inside the main function (library and main function are in same folder) but the header file is not found. What am I doing wrong? Screenshot attached to better show my problem.

screenshot of my problem


Solution

  • You must add the folder in which your facade.h resides in to your include path.

    In your uVision project configuration in the tab C/C++, modify the field Include Paths to contain said folder.