Linking a static C library (MIRACL) to ns-3

471 views
Skip to first unread message

Sai Kishore

unread,
Oct 9, 2013, 4:48:38 PM10/9/13
to ns-3-...@googlegroups.com
I'm trying to use MIRACL library in ns-3. I downloaded the MIRACL library and trying to link the static library (miracl.a)  with ns-3 so that I can use those cryptographic functions in my program. Normally, if I were to run a program using the above mentioned library, I would run with the following command

gcc -m32 myprog.c miracl.a -o myprog.out

With that in mind, I started off with the following changes in the waf script.
    
    obj = bld.create_ns3_program('myprog', ['internet', 'mobility', 'wifi', 'mesh'])
    obj.source = 'myprog.cc'    
    obj.env.append_value("CCFLAGS", ["-I/home/yoda/miracl","-m32"])  
    obj.env.append_value("LINKFLAGS_EXTRA",["-L/home/yoda/miracl/miracl.h"])
    obj.env.append_value("STATICLIB",["miracl"])
    obj.env.append_value("LINKFLAGS",["-L/home/yoda/miracl"])

Now when I run the ns-3 program using the following command

./waf --run examples/tutorial/myprog

I get the following error saying it didn't find the header file. I made sure the path to the header file (miracl.h) and the static library (miracl.a) is correct

../examples/tutorial/myprog.cc:59:22: fatal error: miracl.h: No such file or directory
compilation terminated.

I don't know if I'm missing any flags that need to be set. Could anyone please help me with this?

Thanks,
John

Konstantinos

unread,
Oct 9, 2013, 6:09:53 PM10/9/13
to ns-3-...@googlegroups.com
Have a look at this post


I don't know if there is any change in the waf system that might need to be considered.

John S

unread,
Oct 9, 2013, 6:50:27 PM10/9/13
to ns-3-...@googlegroups.com
Hi Konstantinos

Thanks for the link. I recall going through it before but didn't really help much. I just tried something and it took me a little further but I'm still having problems. I modified 
obj.env.append_value("CCFLAGS", ["-I/home/yoda/miracl","-m32"]

to 

obj.env.append_value("CXXFLAGS", ["-I/home/yoda/miracl","-m32"]

This helped ns-3 find the header file "miracl.h" but now I get a bunch of "undefined reference" errors such as follows

/home/user/ns3/ns-allinone-3.18/ns-3.18/build/../examples/tutorial/mesh.cc:286: undefined reference to `mirvar(int)'

Although all these functions are mentioned as "extern" functions in the header, it is still not able to find these functions. 
Any thoughts??

Tiago Cerqueira

unread,
Jul 18, 2014, 3:22:06 PM7/18/14
to ns-3-...@googlegroups.com
I know this is an old thread but I'm having the exact same problem... Did you find how to get rid of the 'undefined reference' compiler errors?

Thanks!
Reply all
Reply to author
Forward
0 new messages