【问题标题】:How to use LEDA graph library on Omnet++ projects?如何在 Omnet++ 项目中使用 LEDA 图形库?
【发布时间】:2017-03-21 19:09:48
【问题描述】:

我正在尝试在 Omnet++ 4.2.2 中使用 LEDA-6.3 库。我安装了 LEDA 并使用它从 Ubuntu 终端运行了一个简单的程序,没有问题。但是,当我将代码移植到 Omnet++ 时,它失败了。下面是我的简单代码。

    #include <LEDA/graph/graph.h>
    #include <omnetpp.h>

    class cLeda : public cSimpleModule
    {
      protected:
        virtual void initialize();
    };

    Define_Module(cLeda);

    void cLeda::initialize()
    {
        EV << "TestLEDA";
        graph g;
        g.read("nsfnet.txt");
        EV << "No. nodes = " <<g.number_of_nodes() << endl;
    }

我为编译器和链接器的 LEDA 路径配置如下:项目 -> 属性 -> 选择 C/C++ 常规 -> 路径和符号并添加:

  • 对于库路径:/home/grsst/LEDA-6.3/incl
  • 对于库:/home/grsst/LEDA-6.3/libleda.a(我没有添加 libleda.o 因为即使使用 Ubuntu 命令行它也不起作用)
  • 对于库路径:/home/grsst/LEDA-6.3

编译时出现如下错误:

   Description  Resource    Path    Location    Type
   make: *** [all] Error 2  TestLeda            C/C++ Problem
   make[1]: *** [../out/gcc-debug/src/TestLeda] Error 1 TestLeda            C/C++ Problem
   undefined reference to `leda::graph::~graph()'   cLeda.cc    /TestLeda/src   line 26 C/C++ Problem
   undefined reference to `leda::graph::graph()'    cLeda.cc    /TestLeda/src   line 24 C/C++ Problem
   undefined reference to `leda::graph::read(leda::string)' cLeda.cc    /TestLeda/src   line 25 C/C++ Problem
   undefined reference to `leda::memory_manager_init::~memory_manager_init()'   TestLeda        line 145, external               location: /home/grsst/LEDA-6.3/incl/LEDA/system/memory_std.h   C/C++ Problem
   undefined reference to `leda::memory_manager_init::memory_manager_init()'    TestLeda        line 145, external        location: /home/grsst/LEDA-6.3/incl/LEDA/system/memory_std.h  C/C++ Problem
   undefined reference to `leda::memory_manager::deallocate_bytes(void*, unsigned int)' TestLeda        line 52, external location: /home/grsst/LEDA-6.3/incl/LEDA/internal/handle_types.h  C/C++ Problem
   undefined reference to `leda::std_memory_mgr'    TestLeda        line 52, external        location: /home/grsst/LEDA-6.3/incl/LEDA/internal/handle_types.h   C/C++ Problem
   undefined reference to `leda::string::string(char const*)'   cLeda.cc    /TestLeda/src   line 25 C/C++ Problem

我很感激任何可以帮助我实现它的想法。谢谢一百万。

【问题讨论】:

    标签: omnet++


    【解决方案1】:

    OMNeT++ 项目通常使用 Makefile。尝试将LEDA 库添加为Makefrag。 转至Project Properties,选择OMNeT++ | Makemake |选择src | Options | Custom | Makefrag 并写:

        INCLUDE_PATH += -I/home/grsst/LEDA-6.3/incl
        LIBS += -L/home/grsst/LEDA-6.3  -lleda
    

    【讨论】:

    • 不客气。您能否将答案标记为您问题的解决方案?这对其他人会有所帮助。
    • 嗨,Jerzy,我想将我的问题标记为“不知道如何解决”,您能告诉我该怎么做吗?谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多