#ifdef _cplusplus
extern "C"
{
#endif
int myfunc();
#ifdef __cplusplus
}
#endif
在 cpp文件中:
需要:
extern "C" int myfunc(){}
接下来,将cpp文件编译成.o文件,如:g++ -c detect.cpp detect.o
最后将多个.o文件编译成一个.a文件,如ar cr detect.o lan.o libtest.a
在makefile文件中添加对.a的链接,如XLIB -ltest
1701

被折叠的 条评论
为什么被折叠?



