You need to wrap the C code like so
extern "C" { #include "sample1.h" } A better way to do it is like in this StackOverflow questionthis StackOverflow question, in the C header files.
use:
#ifdef __cplusplus extern "C" { #endif At the start of all C header files.
and use:
#ifdef __cplusplus } #endif At the end of all C header files.