【问题标题】:How to use GMP with NS3?如何在 NS3 中使用 GMP?
【发布时间】:2021-07-19 08:47:26
【问题描述】:

在 NS3 中调用 __gmpz_set_str() 时,出现此错误:

__gmpz_set_strcollect2的未定义引用:错误:ld返回1退出状态

我已经包含了#include <gmpxx.h>,并且我还安装了libgmp3-devlibgmp-dev

有什么想法吗? 这是 waf 的链接:https://github.com/nsnam/ns-3-dev-git/blob/master/waf 以及 wscript 的链接:https://github.com/nsnam/ns-3-dev-git/blob/master/wscript

# This is the make file content:

#Makefile wrapper for waf

all:
    ./waf

#free free to change this part to suit your requirements

configure:
    ./waf configure --enable-examples --enable-tests

build:
    ./waf build

install:
    ./waf install

clean:
    ./waf clean

distclean:
    ./waf distclean

【问题讨论】:

标签: c++ makefile gmp ns-3


【解决方案1】:

编译标志需要在配置时设置,所以正确的咒语是:

LDFLAGS=-lgmp ./waf configure

现在,您可以简单地运行 ./waf 来构建整个代码库,并且将使用 -lgmp 标志。如果你真的想使用make(1),那么

LDFLAGS=-lgmp make configure

应该也可以,但我建议直接使用 waf,因为它是实际的构建系统,而不是 make。

【讨论】:

    【解决方案2】:

    将以下内容添加到 Makefile 的顶部:

    export LINKFLAGS = -lgmp
    

    这将与 some lines in the wscript 交互以确保链接器包含 libgmp。

    【讨论】:

    • 不幸的是,我仍然遇到同样的错误。
    猜你喜欢
    • 2012-11-27
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多