将两个c函数从cpp文件中分离出来单独放入一个c文件中,报了下面的错:c++
Undefined symbols for architecture armv7:
"MyEncrypt(unsigned char*, int, unsigned char*, int*, unsigned char*)", referenced from:
MainScene::init() in MainScene.o
"MyDecrypt(unsigned char*, int, unsigned char*, unsigned char*)", referenced from:
MainScene::init() in MainScene.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)函数
非常抓狂啊,为何是Undefined symbols for architecture armv7啊?明明还有arm64的。code
最后的错误缘由感受跟armv7有点风马牛不相及,实际上是很简单的问题,太少写C代码了,竟然把这个也忘记了:
it
If you are using c function in c++ file. you should use extern "c"{}. In .h file
io
#ifdef __cplusplus extern "C" { #endif swrve_currency_given(parameter1, parameter2, parameter3);// a c function #ifdef __cplusplus } #endif