在使用静态链接库时,在头文件内设计接口时如果C语言也为目标使用对象,那么一定要加上如下的代码
#ifndef LIB_H_INCLUDED
#define LIB_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#include <***.h>
#include <abcd.h>//头文件
void func1();//函数声明
void func2();
#ifdef __cplusplus
}
#endif
#endif // LIB_H_INCLUDED
不然在使用时会报错(undefined refrence),因为由于c++支持函数重载,在编译时c++编译器会给每个函数映射一个名字以区分各个函数。