將兩個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