security/commoncap.c:90: error: 'AID_NET_RAW' undeclared

本文详细阐述了解决Android 4.0系统Linux内核编译过程中遇到的配置错误的方法。通过查找并启用关键配置项,成功解决了编译错误,最终实现了内核的正常编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编译安卓4.0系统linux内核时,报错:

CC      security/commoncap.o
security/commoncap.c: In function 'cap_capable':
security/commoncap.c:90: error: 'AID_NET_RAW' undeclared (first use in this function)
security/commoncap.c:90: error: (Each undeclared identifier is reported only once
security/commoncap.c:90: error: for each function it appears in.)
security/commoncap.c:92: error: 'AID_NET_ADMIN' undeclared (first use in this function)
make[1]: *** [security/commoncap.o] Error 1
make: *** [security] Error 2
make: *** Waiting for unfinished jobs....

经过查找,发现定义:

/include/linux/android_aid.h:23:#define AID_NET_RAW      3004

于是打开源文件,查看该文件是否包含,看到如下部分:

#ifdef CONFIG_ANDROID_PARANOID_NETWORK
#include <linux/android_aid.h>
#endif

因此,那原因就是没有定义
CONFIG_ANDROID_PARANOID_NETWORK
进一步搜索发现该定义在net/Kconfig:

config ANDROID_PARANOID_NETWORK
	bool "Only allow certain groups to create sockets"
	default y
	help
		none

终于找到问题所在了,刚开始还纳闷为什么以前编译没有错误,选中该项,问题解决。

android在建立网络连接会进行身份验证,确定是否有权限进行该项操作,因此此处必须加上。

../Core/Src/main.c: In function 'HAL_UART_ErrorCallback': ../Core/Src/main.c:508:5: error: unknown type name 'UART_DMA_State' 508 | UART_DMA_State* state = &uart_state; | ^~~~~~~~~~~~~~ ../Core/Src/main.c:508:30: error: 'uart_state' undeclared (first use in this function); did you mean 'uartStates'? 508 | UART_DMA_State* state = &uart_state; | ^~~~~~~~~~ | uartStates ../Core/Src/main.c:508:30: note: each undeclared identifier is reported only once for each function it appears in ../Core/Src/main.c:513:10: error: request for member 'currentIndex' in something not a structure or union 513 | state->currentIndex = 0; | ^~ ../Core/Src/main.c:514:10: error: request for member 'frameReady' in something not a structure or union 514 | state->frameReady = 0; | ^~ ../Core/Src/main.c:517:38: error: request for member 'activeBuffer' in something not a structure or union 517 | HAL_UART_Receive_DMA(huart, state->activeBuffer, MAX_FRAME_SIZE); | ^~ ../Core/Src/main.c:518:10: error: request for member 'receiving' in something not a structure or union 518 | state->receiving = 1; | ^~ ../Core/Src/main.c:519:10: error: request for member 'lastRxTime' in something not a structure or union 519 | state->lastRxTime = HAL_GetTick(); | ^~ ../Core/Src/main.c:522:10: error: request for member 'errorCount' in something not a structure or union 522 | state->errorCount++; | ^~ ../Core/Src/main.c:523:10: error: request for member 'lastErrorTime' in something not a structure or union 523 | state->lastErrorTime = HAL_GetTick(); | ^~ ../Core/Src/main.c:526:14: error: request for member 'consecutiveErrors' in something not a structure or union 526 | if (state->consecutiveErrors < 255) state->consecutiveErrors++; | ^~ ../Core/Src/main.c:526:46: error: request for member 'consecutiveErrors' in something not a structure or union 526 | if (state->consecutiveErrors < 255) state->consecutiveErrors++; | ^~ ../Core/Src/main.c:529:14: error: request for member 'consecutiveErrors' in something not a structure or union 529 | if (state->consecutiveErrors >= 5) { | ^~ ../Core/Src/main.c:530:9: warning: implicit declaration of function 'emergency_uart_reset' [-Wimplicit-function-declaration] 530 | emergency_uart_reset(huart); | ^~~~~~~~~~~~~~~~~~~~ ../Core/Src/main.c:531:14: error: request for member 'consecutiveErrors' in something not a structure or union 531 | state->consecutiveErrors = 0; // 重置计数器 | ^~ make: *** [Core/Src/subdir.mk:49: Core/Src/main.o] Error 1 make: *** Waiting for unfinished jobs.... "make -j12 all" terminated with exit code 2. Build might be incomplete.
07-19
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值