How can I add a new library to ns3?

1,726 views
Skip to first unread message

NOUR

unread,
Jun 21, 2009, 8:13:10 AM6/21/09
to ns-3-users
Hi,

I need to add an openssl library to ns3 .

Can anybody help me?

Tom Henderson

unread,
Jun 21, 2009, 9:16:59 AM6/21/09
to ns-3-...@googlegroups.com

There are a few examples of this in the code. Some code in src/contrib
uses libxml2 and gtk. Some code in src/devices/wifi uses gsl (gnu
scientific library).

Have a look at src/contrib/wscript or src/devices/wifi/wscript and see
whether you can copy the approach there.

Tom

Vijay Gurbani

unread,
Jun 22, 2009, 9:59:42 AM6/22/09
to ns-3-users
I just went through this ... and I do need to document the process.
It is not straightforward (at least it was not for my case.)

I will put together the steps and send them out later today on the
list.

Thanks,

- vijay

nourhene ellouze

unread,
Jun 22, 2009, 12:31:55 PM6/22/09
to ns-3-...@googlegroups.com
I'm stuck in this step which is essential for the implementation of the EAP protocol.

Please i need your help.

thanks.



De : Vijay Gurbani <vijay....@gmail.com>
À : ns-3-users <ns-3-...@googlegroups.com>
Envoyé le : Lundi, 22 Juin 2009, 15h59mn 42s
Objet : Re: How can I add a new library to ns3?

Vijay Gurbani

unread,
Jun 22, 2009, 6:33:35 PM6/22/09
to ns-3-users
On Jun 22, 11:31 am, nourhene ellouze <nourhene_ello...@yahoo.fr>
wrote:
> I'm stuck in this step which is essential for the implementation of the EAP protocol.

Okay, here are the steps. Will someone from the ns-3 directorate
eyeball this to make sure that they make sense? They did seem to work
for my case.

Linking external libraries in NS-3

Having ns-3 link in external libraries is not as straightforward as I
thought it would be. If you knew the waf system very well, I suspect
that it is fairly transparent, but if you are like me and are using
waf and ns-3 for the first time, it can be a rather daunting
experience to chant the magic incantations that will require ns-3 to
link in an external library. The steps below were gathered by posting
on the ns-3-users Google group; more specifically, Francesco
Malandrino and Gustavo Carniero provided invaluable help and insights.

Here, I will assume the following:

1. You have downloaded, compiled, and regression tested ns-3 (the
version of ns-3 I used in the steps below is ns-3.4).
2. I am interested in adding a libuuid library to ns-3.
3. My application model I am building is in ns-3.4/src/applications/
mymodel

Here are the steps:

1. cd ns-3.4/examples.

2. You are registering a new model in ns-3. So, edit wscript.

3. Add the following lines:

obj = obj.create_ns3_program('mymodel', ['point-to-point',
'internet-stack'])
obj.source = 'mymodel.cc'
obj.env.append_value('LIB', 'uuid')

4. Now cd to ns-3.4/src

5. Edit wscript.

6. Since you are creating a new module (mymodel), add a reference to
it as follows:

def configure(conf):

conf.sub_config('core')
...
conf.sub_config('applications/mymodel') <=== Add this line.

7. cd applications/mymodel (remember, you are already in ns-3.4/src)

8. Edit wscript.

9. Add the lines:

def configure(conf):
conf.check(lib='uuid', define_name='HAVE_UUID', uselib='UUID')

10. cd to ns-3.4 top-level directory.

11. Execute "./waf --run examples/mymodel" and ns-3 should compile and
link with the new library.

12. Have fun.

Patxi Azpiroz

unread,
Nov 5, 2009, 10:22:30 AM11/5/09
to ns-3-...@googlegroups.com
Hi all:
I'm trying to link external libraries in ns-3 but I am not able.
I have try lots of different ways based on many external libraries (like GSL, libxml2, sqlite3,...) used in ns-3 by looking wscript files.

I want to use libxml++ to work with flow monitor xml files.

I have my own files in src/contrib and it worked propertly.

I introduce in src/contrib/wscript file those lines (based on how stats includes sqlite3):
    conf.env['LIBXML++'] = conf.check(lib='libxml++', define_name='LIBXML++', uselib='LIBXML++')
    conf.report_optional_feature("libxml++", "Lib XML ++",
                                conf.env['LIBXML++'],
                                "library 'libxml++' not found")

./waf configure shows the following:
patxi@patxi-HPCompaq:~/pfc/ns-allinone-3.6/ns-3.6$ ./waf configure
Checking for program g++                 : ok /usr/bin/g++
Checking for program cpp                 : ok /usr/bin/cpp
Checking for program ar                  : ok /usr/bin/ar
Checking for program ranlib              : ok /usr/bin/ranlib
Checking for g++                         : ok 
Checking for program pkg-config          : ok /usr/bin/pkg-config
Checking for regression reference traces  : ok ../ns-3.6-ref-traces (guessed)
Checking for -Wno-error=deprecated-declarations support : yes
Checking for -Wl,--soname=foo support                   : yes
Checking for header stdlib.h                            : ok
Checking for header signal.h                            : ok
Checking for header pthread.h                           : ok
Checking for high precision time implementation         : 128-bit integer
Checking for header stdint.h                            : ok
Checking for header inttypes.h                          : ok
Checking for header sys/inttypes.h                      : not found
Checking for library rt                                 : ok
Checking for header netpacket/packet.h                  : ok
Checking for header linux/if_tun.h                      : ok
Checking for pkg-config flags for GTK_CONFIG_STORE      : ok 
Checking for pkg-config flags for LIBXML2               : ok 
Checking for library libxml++ :                            not found

---- Summary of optional NS-3 features:
...
GtkConfigStore                : enabled
XmlIo                         : enabled
Lib XML ++                    : not enabled (library 'libxml++' not found)
SQlite stats data output      : enabled
...

I found the library (ubuntu 8.10) in the shown folder:
 /usr/include/libxml++-2.6/libxml++/libxml++.h
I also tryed putting libxml++-2.6 instead, the absolute path...
I'm spending to much time to go nowhere.

I hope that a more experenced ns-3 (waf) user could give me a hand.
I shouldn't be so difficult, but I can't.

Thanks in advance.

Patxi





2009/6/23 Vijay Gurbani <vijay....@gmail.com>



--
Patxi Azpiroz De Pedro

john

unread,
Nov 20, 2013, 9:49:53 PM11/20/13
to ns-3-...@googlegroups.com
i have the same problem.
i write a file in scrach/testfile.cc ,and there is a header"#include<openssl/evp.h>" in testfile.cc,when i run .waf, there are errors:
......
undefined reference to `EVP_MD_CTX_init'
undefined reference to `EVP_DigestInit_ex'
......
 i think i shoud add a openssl library into ns3,but i don't know how to do that.
could you help me ?

在 2009年6月21日星期日UTC+8下午8时13分10秒,NOUR写道:
Reply all
Reply to author
Forward
0 new messages