[英]Android Studio Error Message: Use Of Undeclared Identifier 'accept4'
the jni folder not appear in android studio and after build only java folder get build . jni 文件夹未出现在android 工作室中,并且在构建后仅java 文件夹获取构建。
as you can see the jni folder appear in explorer but not inside android studio .如您所见, jni 文件夹出现在资源管理器中,但不在android studio中。
EDIT: so after i added this in my build.gradle编辑:所以在我在我的 build.gradle 中添加了这个之后
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
the jni folder appered as cpp folder name but when i compile i get this error from SocketServer.cpp : jni 文件夹显示为cpp 文件夹名称,但是当我编译时,我从SocketServer.cpp收到此错误:
use of undeclared identifier 'accept4'
使用未声明的标识符“accept4”
This is the code:这是代码:
bool SocketServer::Accept() {
if ((acceptfd = accept4(listenfd, nullptr, nullptr, SOCK_CLOEXEC)) < 0) {
Close();
return false;
}
return true;
}
and headers is already includes :并且标头已经包括:
#include <sys/types.h>
#include <sys/socket.h>
i get pass the error " use of undeclared identifier 'accept4'
" by setting these:我通过设置这些来传递错误“
use of undeclared identifier 'accept4'
”:
from compileSdkVersion 29 to compileSdkVersion 30
from buildToolsVersion "29.0.3" to buildToolsVersion "30.0.3"
from minSdkVersion 21 to minSdkVersion 22
from targetSdkVersion 29 to targetSdkVersion 30
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.