首页 > 代码库 > ld: symbol(s) not found for architecture armv7错误

ld: symbol(s) not found for architecture armv7错误

将两个c函数从cpp文件中分离出来单独放入一个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的。

最后的错误原因感觉跟armv7有点风马牛不相及,其实是很简单的问题,太少写C代码了,居然把这个也忘记了:

If you are using c function in c++ file. you should use extern "c"{}. In .h file

#ifdef __cplusplusextern "C" 
{
#endif

swrve_currency_given(parameter1, parameter2, parameter3);// a c function

#ifdef __cplusplus
}
#endif


ld: symbol(s) not found for architecture armv7错误