"Undefined reference to symbol" when create a new class

126 views
Skip to first unread message

Vũ Trần

unread,
Jan 23, 2018, 5:55:08 PM1/23/18
to ns-3-users
Hello everyone,

I have 2 file test_interleaver.cc and test_interleaver.h in folder /scratch/interleaver
https://gist.github.com/raindayqb/eef160f7cc02afe5df2d62999fdeb51a

But when I execute ./waf --run=interleaver, I get the error message

./waf --run=interleaver
Waf: Entering directory `/home/rainyday/git/PhySim/ns-3.27/build'
[1000/2628] Compiling scratch/interleaver/test_interleaver.cc
[2609/2628] Linking build/scratch/interleaver/interleaver
/usr/bin/ld: scratch/interleaver/test_interleaver.cc.4.o: undefined reference to symbol '_ZN4itpp3VecIiEC1ERKNS_7FactoryE'
/usr/local/lib/libitpp.so.8: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

I put almost all code in comment. I walked around for a long time and I realize when I try to redefine a function like constructor or any data member, member functions of class prototype, I will get that error.

Appreciate if someone could help. Thank you.

Tommaso Pecorella

unread,
Jan 25, 2018, 12:12:02 AM1/25/18
to ns-3-users
Hi,

it's a linking problem - it seems that you're not adding the "itpp" library to ns-3.
You'll need to add it to the linking options, check the group for infos on how to add external libraries to ns-3.

T.

Vũ Trần

unread,
Jan 26, 2018, 5:00:32 AM1/26/18
to ns-3-users
Thank you very much, I've solved my problem.
I edited wscript file in the ns-3 main folder and did a rebuild.

    conf.find_program('libgcrypt-config', var='LIBGCRYPT_CONFIG', msg="python-config", mandatory=False)
   
if env.LIBGCRYPT_CONFIG:
        conf
.check_cfg(path=env.LIBGCRYPT_CONFIG, msg="Checking for libgcrypt", args='--cflags --libs', package='',
                                     define_name
="HAVE_CRYPTO", global_define=True, uselib_store='GCRYPT', mandatory=False)
    conf
.report_optional_feature("libgcrypt", "Gcrypt library",
                                 conf
.env.HAVE_GCRYPT, "libgcrypt not found: you can use libgcrypt-config to find its location.")

    have_itpp = conf.check_cfg(package='itpp', args=['--cflags', '--libs'],
                              uselib_store
='ITPP', mandatory=True)
    conf
.env['ENABLE_ITPP'] = have_itpp
    conf
.report_optional_feature("ITPP", "itpp", conf.env['ENABLE_ITPP'], "ITPP not found")  
   
# if conf.env['ENABLE_ITPP']:
    conf
.env.append_value('CXXFLAGS', '-DNO_INT_SIZE_CHECK')
    conf
.env.append_value('CXXFLAGS', '-Wall')
    conf
.env.append_value('CXXFLAGS', '-g')
    conf
.env.append_value('CXXFLAGS', '-DNDEBUG')
    conf
.env.append_value('CXXFLAGS', '-pipe')                    
    conf
.env.append_value('INCLUDES', '/usr/local/include')
    conf
.env.append_value('LINKFLAGS', '-L/usr/local/lib')
    conf
.env.append_value('LINKFLAGS', '-litpp')      
Reply all
Reply to author
Forward
0 new messages