解决DOCA官方例程 ninja 编译错误

在测试DOCA给的应用firewall在进行编译的时候出现错误如下:

1、

sun@sun-G3-3590:/opt/mellanox/doca/applications$ sudo meson build
The Meson build system
Version: 0.61.2
Source dir: /opt/mellanox/doca/applications
Build dir: /opt/mellanox/doca/applications/build
Build type: native build
Program cat found: YES (/usr/bin/cat)
Project name: DOCA_APPLICATIONS
Project version: 1.4.0079
C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C linker for the host machine: cc ld.bfd 2.34
C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C++ linker for the host machine: c++ ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Found CMake: /usr/bin/cmake (3.16.3)
Run-time dependency libdpdk found: NO (tried cmake)

meson.build:32:0: ERROR: Could not generate cargs for libdpdk:
Package libmlx4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmlx4.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libmlx4', required by 'libdpdk', not found


A full log can be found at /opt/mellanox/doca/applications/build/meson-logs/meson-log.txt

解决方案:

在root环境下运行:

root@sun-G3-3590:/opt/mellanox/doca/applications# meson build
The Meson build system
Version: 0.61.2
Source dir: /opt/mellanox/doca/applications
Build dir: /opt/mellanox/doca/applications/build
Build type: native build
Program cat found: YES (/usr/bin/cat)
Project name: DOCA_APPLICATIONS
Project version: 1.4.0079
C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C linker for the host machine: cc ld.bfd 2.34
C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C++ linker for the host machine: c++ ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Run-time dependency libdpdk found: YES 20.11.5.2.2
Run-time dependency threads found: YES
Run-time dependency libbsd found: YES 0.10.0
Run-time dependency doca-argp found: YES 1.4.0079
Run-time dependency doca-flow found: YES 1.4.0079
Run-time dependency doca-common found: YES 1.4.0079
Dependency doca-argp found: YES 1.4.0079 (cached)
Run-time dependency doca-flow-grpc found: YES 1.4.0079
Dependency doca-common found: YES 1.4.0079 (cached)
Build targets in project: 2

Found ninja-1.12.0.git at /usr/bin/ninja

2、找不到json-c/json.h文件

linux-gnu/librte_telemetry.so /opt/mellanox/dpdk/lib/x86_64-linux-gnu/librte_kvargs.so /usr/lib/x86_64-linux-gnu/libbsd.so -pthread -Wl,--as-needed /opt/mellanox/doca/lib/x86_64-linux-gnu/libdoca_argp.so -Wl,--as-needed /opt/mellanox/doca/lib/x86_64-linux-gnu/libdoca_flow_grpc.so -Wl,--as-needed /opt/mellanox/doca/lib/x86_64-linux-gnu/libdoca_common.so -Wl,--end-group
/usr/bin/ld: firewall/src/doca_firewall.p/firewall_core.c.o: undefined reference to symbol 'json_object_array_length'
/usr/bin/ld: /lib/x86_64-linux-gnu/libjson-c.so.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

解决方案:

参考:

https://zhangboyi.gitlab.io/post/2020-09-14-resolve-dso-missing-from-command-line-error/

运行:

export LDFLAGS="-Wl,--copy-dt-needed-entries"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A: 可以使用Java编程语言来创建一个文档管理器。以下是一个简单的实现示例: ```java import java.util.HashMap; public class DocumentManager { private HashMap<String, String> templates; // 构造函数 public DocumentManager() { templates = new HashMap<String, String>(); } // 添加新的文档模板 public void addTemplate(String name, String content) { templates.put(name, content); } // 创建新的文档 public String createDocument(String templateName) { String template = templates.get(templateName); if (template == null) { return "指定的模板不存在,请确认后重试"; } // 假设这里采用字符串替换的方式将模板内容转换为新的文档内容 String document = template.replace("{{name}}", "新建文档"); return document; } // 获取现有模板的列表 public String getTemplatesList() { String list = ""; for (String name : templates.keySet()) { list += name + "\n"; } if (list.isEmpty()) { list = "当前没有任何模板"; } return list; } } ``` 使用示例: ```java public class Main { public static void main(String[] args) { DocumentManager manager = new DocumentManager(); // 添加两个模板 manager.addTemplate("模板A", "这是模板A,名称为{{name}}。"); manager.addTemplate("模板B", "这是模板B,名称为{{name}},属性1为{{prop1}},属性2为{{prop2}}。"); // 输出现有模板列表 System.out.println(manager.getTemplatesList()); // 创建新的文档(模板A) String docA = manager.createDocument("模板A"); System.out.println(docA); // 创建新的文档(模板B) String docB = manager.createDocument("模板B"); System.out.println(docB); } } ``` 输出结果: ``` 模板A 模板B 这是模板A,名称为新建文档。 这是模板B,名称为新建文档,属性1为,属性2为。 ``` 这个示例中,我们使用了HashMap来存储文档模板。添加新的模板可以通过addTemplate函数实现,函数接受两个参数,一个是模板的名称,另一个是模板的内容。 要创建新的文档,我们需要调用createDocument函数。该函数接受模板的名称作为参数,并试图获取模板的内容。如果模板不存在,函数将返回一个错误信息。否则,我们将使用字符串替换的方式将模板内容转换为新的文档内容,这里只演示了一种简单的替换方式。最终,函数将返回新的文档内容。 我们还实现了一个getTemplatesList函数,以便查看现有模板的名称列表。如果列表为空,则该函数将返回一个相应的消息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值