The reason for the error you get is that by including the header file that you are telling the compiler, there is a character
int add (int, int)
This will be present during the binding, but you have not actually included this symbol (code for the function) in your project. A quick way to solve the problem is to simply add Add.cpp to both projects. But the βniceβ solution would probably be to make SimpleMath in the library instead of the application, changing the project type in the project properties.
And by the way, you probably need some mechanism to prevent multiple inclusion of this header file in place. I usually use #pragma once , which should be fine if you stick with Visual C ++, but it may not be completely portable, so if you want to port, go on to a more traditional approach to wrapping the header file in #ifndef -block, as such
#ifndef __ADD_H #define __ADD_H int add (int i, int j); #endif
Good luck.
source share