libconfig library linking problem

1,416 views
Skip to first unread message

Gevorg Poghosyan

unread,
Oct 17, 2012, 10:35:12 AM10/17/12
to ns-3-...@googlegroups.com
Dear community,

It seems I have successfully installed the libconfig library that I use in my ns3 code, but when building with waf I get the following errors
/home/gevra/repos/ns-3-allinone/ns-3.15/build/../scratch/include_file.inc:36: undefined reference to `libconfig::Config::Config()'
/home/gevra/repos/ns-3-allinone/ns-3.15/build/../scratch/include_file.inc:41: undefined reference to `libconfig::Config::readFile(char const*)'
/home/gevra/repos/ns-3-allinone/ns-3.15/build/../scratch/include_file.inc:44: undefined reference to `libconfig::Config::lookup(char const*) const'
/home/gevra/repos/ns-3-allinone/ns-3.15/build/../scratch/include_file.inc:51: undefined reference to `libconfig::Setting::operator[](int) const'
/home/gevra/repos/ns-3-allinone/ns-3.15/build/../scratch/include_file.inc:51: undefined reference to `libconfig::Setting::operator int() const'
.....
 
So I guess the linking of library was not successful...

Can you please help me with linking this library to my program, or to give a hint how can I run waf so it recognizes the library?

Thanks in advance!

Gevorg

P.S. it's not for a module, but for a program in scratch/

Mitch Watrous

unread,
Oct 17, 2012, 7:05:38 PM10/17/12
to ns-3-...@googlegroups.com
Have you included the libconfig class header file in your program,

    /scratch/include_file.inc

Mitch

Gevorg Poghosyan

unread,
Oct 18, 2012, 4:31:10 AM10/18/12
to ns-3-...@googlegroups.com
no, but I have the #include <libconfig.h++> in my scratch/test_intersession.cc.
include_file.inc is included in this cc file.

the program worked normally on MAC OS with ns-3.4... now I need to work on ns-3.15 on Ubuntu.

Mitch Watrous

unread,
Oct 18, 2012, 12:18:08 PM10/18/12
to ns-3-...@googlegroups.com
Have a look at this wiki that talks about linking ns3 with other libraries:

    http://www.nsnam.org/wiki/index.php/HOWTO_use_ns-3_with_other_libraries

Mitch

Gevorg Poghosyan

unread,
Oct 18, 2012, 2:51:48 PM10/18/12
to ns-3-...@googlegroups.com
Yes Mitch,
I have tried this solution but it doesn't work... the link you have posted is for modules. In my case I did the same for the top level wcscript cause my file is in scratch/ folder.

Mitch Watrous

unread,
Oct 18, 2012, 5:19:12 PM10/18/12
to ns-3-...@googlegroups.com
Have a look at this ns-3-users thread and do the same thing with your program, i.e. move it out of scratch and put it into a new example directory that you will create with a new wscript file that you will create, too:

    https://groups.google.com/forum/#!searchin/ns-3-users/anders/ns-3-users/4cFI7fRKJRg/mfg_3Qe2-owJ

Mitch

Gevorg Poghosyan

unread,
Oct 19, 2012, 3:39:26 PM10/19/12
to ns-3-...@googlegroups.com
Thanks for the link Mitch.
unfortunately I get the very same error...

I will also ask Gustavo on that post...

Mitch Watrous

unread,
Oct 19, 2012, 7:15:04 PM10/19/12
to ns-3-...@googlegroups.com
Are you sure about the paths you used in your wscript file and the location of this libconfig library and its header files?

Can you send your new example's wscript file and it's C++ code.

Mitch

Mitch Watrous

unread,
Oct 19, 2012, 7:45:49 PM10/19/12
to ns-3-...@googlegroups.com
Another thing you might try is to turn your files into a module with your scratch directory program as an example in that module.

Here are instructions for creating a new module in ns-3: 

        http://www.nsnam.org/docs/release/3.15/manual/html/new-modules.html
   
Then, follow the instructions for linking modules with external libraries.

Mitch

Gevorg Poghosyan

unread,
Oct 20, 2012, 10:12:31 AM10/20/12
to ns-3-...@googlegroups.com
I am not sure, but I think I did correctly...
I put my files(test_intersession.cc and include_file.inc) in .../examples/intersession/
please download the wscript file from this directory here: https://www.dropbox.com/s/7sdrhfaruuzib62/wscript

I had also created a module "net-coding" for my program according to those instructions in the manual.

now I will try to put the .cc file in my module's directory and specify it as an example for the module...

Gevorg Poghosyan

unread,
Oct 20, 2012, 10:42:15 AM10/20/12
to ns-3-...@googlegroups.com
Hi Mitch.
I didn't get well the idea of making the program an example for a module... probably I did it wrongly... I didn't manage to make it work...
can you please explain me in more details?

Mitch Watrous

unread,
Oct 22, 2012, 8:20:55 PM10/22/12
to ns-3-...@googlegroups.com
Try this build function:

    def build(bld):
        obj = bld.create_ns3_program('test_intersession', ['net-coding'])
        obj.env.append_value('LIBS', "libconfig++")
        obj.env.append_value('INCLUDES', "/usr/local/include")
        obj.env.append_value('LINKFLAGS', ["-L/usr/local/lib", "-lconfig++"])
        obj.source = 'test_intersession.cc'


Also, should this line

        have_libconfig = conf.pkg_check_modules('LIBCONFIG', 'libconfig', mandatory=False)

be

        have_libconfig = conf.pkg_check_modules('LIBCONFIG', 'libconfig++', mandatory=False)

Mitch

Gevorg Poghosyan

unread,
Nov 2, 2012, 10:44:05 AM11/2/12
to ns-3-...@googlegroups.com
Hi Mitch!

Sorry for my late reply, my supervising PhD finally found a solution.
So what she did is the following:

in the top-level wscript file she added
have_libconfig = conf.pkg_check_modules('LIBCONFIG', 'libconfig++', mandatory=False)
    conf.env['ENABLE_LIBCONFIG'] = have_libconfig

    conf.report_optional_feature("LIBCONFIG", "Libconfig parsing library",
                                 conf.env['ENABLE_LIBCONFIG'],
                                 "LIBCONFIG not found")
    if have_libconfig:
        conf.env.append_value('DEFINES', "ENABLE_LIBCONFIG")
like for gsl...

in the wscript of the module she added
if bld.env['ENABLE_LIBCONFIG']:
        module.use.extend(['LIBCONFIG'])
        module_test.use.extend(['LIBCONFIG'])

and in the module she created a cc file which was reading the input file including the libconfig library.

It worked! 

Thank you for your support! 
Reply all
Reply to author
Forward
0 new messages