HarmonyOS native audio 录制编译报错

/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/llvm/bin/clang++ --target=aarch64-linux-ohos --gcc-toolchain=/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/llvm --sysroot=/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/sysroot  -Dcorelib_EXPORTS -I/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/hms/native/sysroot/usr/include -I/Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp -I/Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp/include -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -D__MUSL__ -O0 -g -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/corelib.dir/hello.cpp.o -MF CMakeFiles/corelib.dir/hello.cpp.o.d -o CMakeFiles/corelib.dir/hello.cpp.o -c /Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp/hello.cpp 
clang++: warning: argument unused during compilation: '--gcc-toolchain=/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/llvm' [-Wunused-command-line-argument] 
In file included from /Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp/hello.cpp:6: 
In file included from /Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp/AudioRecordWrap.h:7: 
In file included from /Users/chenyun/projects/harmonyOs/harmonyOs-lib/corelib/src/main/cpp/AudioRecord.h:16: 
In file included from /Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/sysroot/usr/include/sys/stat.h:23: 
/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/sysroot/usr/include/aarch64-linux-ohos/bits/stat.h:1:8: error: redefinition of 'stat' 
struct stat { 
       ^ 
/Users/chenyun/Library/Huawei/Sdk/openharmony/X86SDK/HarmonyOS-NEXT-DP2/base/native/sysroot/usr/include/asm-generic/stat.h:23:8: note: previous definition is here 
struct stat { 
       ^ 
1 error generated. 
ninja: build stopped: subcommand failed. 
	 Detail: Please check the message from tools. 
> hvigor ERROR: BUILD FAILED in 4 s 16 ms
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
HarmonyOS
2024-11-12 08:45:09
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa

​提供的代码是native用法,C接口不能这么用,需要用OH_AVBUFFER的相关接口,可以参考以下链接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/_core-V5#oh_avbuffer_create

需要改成接口的写法​。

OH_AVBuffer_Create() 
OH_AVBuffer_Destroy() 
OH_AVBuffer_GetAddr() 
OH_AVBuffer_GetBufferAttr() 
OH_AVBuffer_GetCapacity() 
OH_AVBuffer_GetNativeBuffer() 
OH_AVBuffer_GetParameter() 
OH_AVBuffer_SetBufferAttr() 
OH_AVBuffer_SetParameter() 
OH_AVFormat_Copy() 
OH_AVFormat_Create()
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

用这些。

分享
微博
QQ
微信
回复
2024-11-12 17:27:16
相关问题
HarmonyOS flutter依赖插件audio_session报错
711浏览 • 1回复 待解决
HarmonyOS 视频录制报错
867浏览 • 1回复 待解决
HarmonyOS audio.AudioRenderer
485浏览 • 1回复 待解决
HarmonyOS 编译flutter报错
1014浏览 • 1回复 待解决
HarmonyOS react-native应用编译失败
858浏览 • 1回复 待解决
HarmonyOS NDK 运行编译报错
1232浏览 • 1回复 待解决
编译报错没有堆栈信息
1619浏览 • 1回复 待解决
openharmony 交叉编译openjdk报错
1839浏览 • 1回复 待解决
HarmonyOS 开启编译字节码Har报错
973浏览 • 1回复 待解决
HarmonyOS ets替换ts编译报错问题
1054浏览 • 1回复 待解决
编译报错Found exception如下
2760浏览 • 1回复 待解决