linker-errors - ns-3 waf 链接错误(未定义的引用)
问题描述
由于调用./waf
. 我已经正确安装了 gcrypt,因为下面的程序在使用g++ test.cpp -o test -lgcrypt
.
#include <stdio.h>
#include <gcrypt.h>
int main(void)
{
char *s = "some text";
unsigned char *x;
unsigned i;
unsigned int l = gcry_md_get_algo_dlen(GCRY_MD_SHA256); /* get digest length (used later to print the result) */
gcry_md_hd_t h;
gcry_md_open(&h, GCRY_MD_SHA256, GCRY_MD_FLAG_SECURE); /* initialise the hash context */
gcry_md_write(h, s, strlen(s)); /* hash some text */
x = gcry_md_read(h, GCRY_MD_SHA256); /* get the result */
for (i = 0; i < l; i++)
{
printf("%02x", x[i]); /* print the result */
}
printf("\n");
return 0;
}
但是,在 ns-3 中复制此代码会产生与以下链接错误类似类型的多个错误:
/home/xxx/Desktop/ns-allinone-3.28.1/ns-3.28.1/build/../scratch/ns3consensus/AppCons.cc:251: undefined reference to `gcry_md_get_algo_dlen'
此外,ns-3 本身似乎认识到 gcrypt 已安装,因为 的输出./waf configure
表明 gcrypt 库已安装Gcrypt library : enabled
.
我已按照https://www.nsnam.org/wiki/HOWTO_use_ns-3_with_other_librariesconf.env.append_value("LINKFLAGS", ["-lgcrypt"])
的建议添加到顶级 wscript ,但问题仍然存在。是否需要添加任何其他内容来添加 wscript,或者是否还有其他一些我缺少的链接基础知识?
解决方案
这个问题的答案是如何将库包含在waf
.
- 包括由
cfg.env.append_value('INCLUDES', ['/usr/local/include'])
, - 库搜索路径由
conf.env.append_value('LIBPATH', ["/usr/local/lib"])
和添加 - 在检查/编译/链接时,您使用关键字use=name_of_the_library,因此在这里它会是
use='gcrypt'
。
推荐阅读
- c# - 不支持 SpreadsheetDocument.Create() 返回 URI 格式
- swift - 如何使用 Core bluetooth Framework 在 iOS 13 中发现经典蓝牙设备
- redis - Redis:集群新增节点后是否需要重新平衡哈希槽
- javascript - 如何在保存模式下打开向导操作还隐藏编辑、创建、保存和丢弃按钮 Odoo11
- visual-studio-code - vscode导航查找不适用于反应项目的参考
- php - 无法从 php 中的 url 中提取令牌
- entity - DDD 和 CQRS - 为调度用例定义实体
- xamarin.forms - Xamarin 滑块控件 - 行未显示
- javascript - React-Native 格式剪贴板数据
- influxql - 将标签与 InfluxDB“SELECT *”结果中的字段区分开来