HarmonyOS ndk编译mars库失败

mars库:https://github.com/Tencent/mars

编译该库出现错误:

make[1]: Entering directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
make[2]: Entering directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
Scanning dependencies of target f3clog 
make[2]: Leaving directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
make[2]: Entering directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
[  3%] Building CXX object CMakeFiles/f3clog.dir/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp.o 
clang++: warning: argument unused during compilation: '--gcc-toolchain=/mnt/d/harmonyos-sdk/HarmonyOS-NEXT-DP2/base/native/llvm' [-Wunused-command-line-argument] 
In file included from /mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:2: 
In file included from /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/mars/comm/xlogger/xloggerbase.h:27: 
/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/mars/comm/assert/__assert.h:35:1: error: unknown type name '__BEGIN_DECLS' 
__BEGIN_DECLS 
  ^ 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/mars/comm/assert/__assert.h:46:1: error: unknown type name '__END_DECLS' 
__END_DECLS 
  ^ 
  In file included from /mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:2: 
/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/mars/comm/xlogger/xloggerbase.h:31:8: error: expected unqualified-id 
extern "C" { 
  ^ 
  /mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:56:5: error: unknown type name 'XLoggerInfo' 
  XLoggerInfo info; 
  ^ 
  /mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:57:19: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
  info.level = (TLogLevel)m_info.level; 
  ^~~~~~~~~ 
  FTLogLevel 
    /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:224:32: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
if (!xlogger_IsEnabledFor((TLogLevel)level)) 
^~~~~~~~~ 
FTLogLevel 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:224:10: error: use of undeclared identifier 'xlogger_IsEnabledFor' 
if (!xlogger_IsEnabledFor((TLogLevel)level)) 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:232:5: error: unknown type name 'XLoggerInfo' 
XLoggerInfo info; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:233:19: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
info.level = (TLogLevel)level; 
^~~~~~~~~ 
FTLogLevel 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:247:32: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
if (!xlogger_IsEnabledFor((TLogLevel)level)) 
^~~~~~~~~ 
FTLogLevel 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:247:10: error: use of undeclared identifier 'xlogger_IsEnabledFor' 
if (!xlogger_IsEnabledFor((TLogLevel)level)) 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:262:23: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
xlogger_SetLevel((TLogLevel)level); 
^~~~~~~~~ 
FTLogLevel 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:262:5: error: use of undeclared identifier 'xlogger_SetLevel' 
xlogger_SetLevel((TLogLevel)level); 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:266:34: error: unknown type name 'TLogLevel'; did you mean 'FTLogLevel'? 
return xlogger_IsEnabledFor((TLogLevel)level); 
^~~~~~~~~ 
FTLogLevel 
  /mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/../../../../Src/ftlog/api/c++/FTLogDef.h:46:3: note: 'FTLogLevel' declared here 
} FTLogLevel; 
^ 
/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp:266:12: error: use of undeclared identifier 'xlogger_IsEnabledFor' 
return xlogger_IsEnabledFor((TLogLevel)level); 
^ 
15 errors generated. 
make[2]: *** [CMakeFiles/f3clog.dir/build.make:63: CMakeFiles/f3clog.dir/mnt/d/harmonyos-sdk/FTLog/Src/ftlog/api/c++/FTLog.cpp.o] Error 1 
make[2]: Leaving directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/f3clog.dir/all] Error 2 
make[1]: Leaving directory '/mnt/d/harmonyos-sdk/FTLog/Proj/HarmonyOS/FTLog/cpp/64build' 
make: *** [Makefile:84: all] Error 2

问题二:为什么会出现。

error: field has incomplete type 'struct timeval'     struct timeval timeval;

必须要手动#include <sys/time.h>才能解决这个错误。

HarmonyOS
2024-09-12 11:44:05
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa

1、当前HarmonyOS已经提供mars库:https://gitee.com/openharmony-sig/mars

2、编译什么能力的时候报错sys/time.h的依赖找不到?可以检查以下当前sys目录下面是否有time.h这个文件?

3、__BEGIN_DECLS 和 _END_DECLS通常用来定义extern"C" {,所以能否直接把__BEGIN_DECLS 和 __END_DECLS替换成__BEGIN_EXTERN_C 和 __END_EXTERN_C要看__BEGIN_EXTERN_C 和 __END_EXTERN_C的定义是否也是如此。

分享
微博
QQ
微信
回复
2024-09-12 16:45:30
相关问题
HarmonyOS tencent mars适配问题
238浏览 • 1回复 待解决
HarmonyOS有移植mars吗?
916浏览 • 1回复 待解决
HarmonyOS NDK编译错误
406浏览 • 1回复 待解决
NDK开发是否有提供交叉编译工具
1722浏览 • 1回复 待解决
HarmonyOS windows系统下编译失败
249浏览 • 0回复 待解决
HarmonyOS RN empty project编译失败
74浏览 • 1回复 待解决
HarmonyOS 如何下载NDK
454浏览 • 1回复 待解决
HarmonyOS C++使用aki编译报错
225浏览 • 1回复 待解决
macOS 编译 Paddle-Lite 失败
769浏览 • 1回复 待解决
HarmonyOS 数据dataORM插入数据失败
120浏览 • 1回复 待解决
HarmonyOS 怎么交叉编译curl、openssl
155浏览 • 1回复 待解决
hi3861编译失败的原因
11220浏览 • 2回复 待解决
缺失getcontext函数导致breakpad编译失败
820浏览 • 1回复 待解决
OpenHarmony-2.2-Beta2 编译失败,求助
8651浏览 • 1回复 已解决
泛型参数转换为Object编译失败
572浏览 • 1回复 待解决
编译hispark, pegasus, hi3861, wifi 代码失败
8093浏览 • 1回复 待解决
编译OpenHarmony2.0失败,求助一下
8789浏览 • 3回复 已解决