我正在尝试使用AndroidJniBitmapOperations库。但我是一名初级开发人员,对 NDK、JNI 世界一无所知。
我成功解决了一些错误,例如“UnsatisfiedLinkError”,但现在当我尝试构建时遇到了一个新错误:
错误:未定义对“AndroidBitmap_unlockPixels”的引用
另外,我在 CPP 文件中发现了一些错误:
1.“参数‘prmeterName’的类型不正确,其类型应为‘jint’。
2.“添加外部'C'”
但我不确定最后两个是否重要。
帮助我更新这个库,因为它很重要并且多次讨论过,例如:here。
库本身的链接: https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations
到目前为止我所做的一切是: https: //github.com/LiorA1/MyRevApp
我是新来的c&我遇到了一个新问题..
file1.c-
#include <stdio.h>
#include <stdlib.h>
extern int sec();
char *ptr=NULL;
int main(){
char *ptr=NULL;
ptr=(char*)calloc(sizeof(char),8);/*8 chars.*/
*(ptr+0)='0'; /*first char set to 0.*/
printf("%c\n",*ptr);
*(ptr+0)='r';
*(ptr+1)='o';
*(ptr+2)='i';
*(ptr+3)='L';
printf("%c %c %c %c \n",*(ptr+0),*(ptr+1),*(ptr+2),*(ptr+3));
sec();
return 0;}
Run Code Online (Sandbox Code Playgroud)
和file2.c-
#include <stdio.h>
#include <stdlib.h>
extern char *ptr;
void sec(void){
puts("before.");
*(ptr+0)='L';/*CARSH HERE.*/
*(ptr+1)='i';
*(ptr+2)='o';
*(ptr+3)='r';
puts("after.");
printf("%c %c %c %c ",*(ptr+0),*(ptr+1),*(ptr+2),*(ptr+3));
free(ptr);}
Run Code Online (Sandbox Code Playgroud)
我之前做过类似的事(有一点不同),但现在它崩溃了.是什么原因 ?.如果我将在源文件中构建一个函数,在哪里分配了内存,它将被解决?