Link NS3 program with external library (CGAL)

64 views
Skip to first unread message

Lahis Gomes de Almeida

unread,
Sep 13, 2021, 6:13:35 PM9/13/21
to ns-3-users
Hi everybody!

I'm trying to use CGAL lib in my ns3 code. I decide to create a new module and use a wscript to enable CGAL usage, but didn't work.  Here is my wscript:

def build(bld):
    module = bld.create_ns3_module('new-module', ['core'])
    module.source = [
        'model/new-module.cc',
        'helper/new-module-helper.cc',
        ]

    module_test = bld.create_ns3_module_test_library('new-module')
    module_test.source = [
        'test/new-module-test-suite.cc',
        ]

    module.env.append_value("CXXFLAGS", "-I/home/wasp/CGAL-5.3/include")
    module.env.append_value("LINKFLAGS", ["-L/home/wasp/CGAL-5.3/lib"])
    module.env.append_value("LIB", ["CGAL"])

    # Tests encapsulating example programs should be listed here
    if (bld.env['ENABLE_EXAMPLES']):
        module_test.source.extend([
        #    'test/new-module-examples-test-suite.cc',
             ])

    headers = bld(features='ns3header')
    headers.module = 'new-module'
    headers.source = [
        'model/new-module.h',
        'helper/new-module-helper.h',
        ]

    if bld.env.ENABLE_EXAMPLES:
        bld.recurse('examples')



Here is build response:

[1980/2041] Compiling contrib/new-module/helper/new-module-helper.cc
[1981/2041] Compiling contrib/new-module/model/new-module.cc
[1995/2041] Linking build/lib/libns3-dev-new-module-debug.so

/usr/bin/ld: cannot find -lCGAL
collect2: error: ld returned 1 exit status

Am I missing something?

Tks!

Gabriel

unread,
Sep 13, 2021, 8:59:43 PM9/13/21
to ns-3-users
Did you try removing the library? Based on their repo, you don't need to link anything. :)

```
Since version 5.0, CGAL is a header-only library, meaning that it is no longer needed to build CGAL libraries before it can be used.
```
Source: https://github.com/CGAL/cgal

Lahis Gomes de Almeida

unread,
Sep 15, 2021, 3:13:24 PM9/15/21
to ns-3-users
Tks! It worked!
Reply all
Reply to author
Forward
0 new messages