안녕하세요.
JNI 쪽 개발을 하고 있는데...
우선 .cpp 파일에서 .c 파일안의 함수를 호출하니
undefined reference to `return_five' // .c 파일안에 있는 return_five() 함수
라는 오류가 발생합니다.
.c 파일을 .cpp 로 해주면 해결이 되지만...
꼭 .c 로 해야 할 일이 있어서요...
#ifdef __cplusplus
extern "C" {
#endif
int return_five();
#ifdef __cplusplus
}
#endif
를 해줘도 그러네요... 잘못 사용하고 있는 건지...
test.c 파일
#include <iostream>
#include "testcall.h"
int return_five()
{
return 5;
}
test.h
#ifdef __cplusplus
extern "C" {
#endif
int return_five();
#ifdef __cplusplus
}
#endif
.native 코드가 구현되어 있는 .cpp 에서
int five = return_five();
호출시
Error:(73) undefined reference to `return_five'
뭔가 다른걸 해줘야 하는 건가요???
같은 환경에서 파일명만 .c -> .cpp 로 변경시 해당 오류 해결이 됩니다.
뭔가요.. 대체... ㅠㅠ