how can I link gmp library to my ns3?

155 views
Skip to first unread message

Jenny Lee

unread,
Nov 23, 2017, 5:09:40 AM11/23/17
to ns-3-users
I am a newbird. I am now trying to add gmp library to my ns3.
I simply changed this file ns-3/src/ndnSIM/examples/ndn-simple.cpp to do my experiment. So I changed the wscript file in ns-3/src/ndnSIM/examples/wscript as follows:
def configure(conf):
    conf.env.append_value("LINKFLAGS", ["-L/usr/local/lib/gmp.a","-Lgmp"])
    conf.env.append_value("LIB", ["gmp"])
did not linked successfully, then changed like this:
def build(bld):
    bld.env.append_value("CXXFLAGS", "-I/usr/local/include")
    bld.env.append_value("LINKFLAGS", ["-L/usr/local/lib"])
    bld.env.append_value("LIB", ["gmp"])
still not linked.ε=(´ο`*)))
can anyone tell me what to do? thank you so much!

Tommaso Pecorella

unread,
Nov 23, 2017, 4:55:50 PM11/23/17
to ns-3-users
Hi,

no idea, but try to follow this:

T.

Jenny Lee

unread,
Nov 24, 2017, 2:44:22 AM11/24/17
to ns-3-users
Hey, thanks a lot for the attention. My problem has been solved. I thought it was very difficult, but it tends out to be my careless mistakes.
I copyed the gmp.so.1 file into the /usr/lib file, and used a simple code to solve my problem. ε=(´ο`*)))
 obj.env.append_value('LIB', 'gmp')
really embarrassed. hope my experience can save others time.

在 2017年11月24日星期五 UTC+8上午5:55:50,Tommaso Pecorella写道:

madhurima buragohain

unread,
Mar 15, 2018, 8:39:58 AM3/15/18
to ns-3-users
I have tried the same way, but it is not working.

Following error is coming.

n function `main':

/root/Desktop/ndn-cxx/ndnSIM/Lixia/ns-3/build/../scratch/scratch-simulator.cc:28: undefined reference to `__gmpz_init'

collect2: error: ld returned 1 exit status



Could you please post the wscript file as a whole so that i can match with mine.


Thanking You,


Madhurima Buragohain

Indian Institute of Technology, Guwahati

Isaac Osunkunle

unread,
Mar 16, 2018, 10:09:57 PM3/16/18
to ns-3-users

 To use C library function use extern "C" as below in your .cpp program , myprog.cpp
extern "C" {
    // C Function call
    cfunc();
}

int main()
{
    cfunc();
    return 0;
}

ningchun liu

unread,
Apr 13, 2020, 8:46:26 AM4/13/20
to ns-3-users
Hi,I meet the same problem. Have you solve it?

在 2018年3月15日星期四 UTC+8下午8:39:58,madhurima buragohain写道:

ningchun liu

unread,
Apr 13, 2020, 8:49:36 AM4/13/20
to ns-3-users
Hi,I meet the same problem. When I follow these steps from your post, the gmp and pbc libraries are still not linked.Have you solve it?

在 2017年11月23日星期四 UTC+8下午6:09:40,Jenny Lee写道:
Reply all
Reply to author
Forward
0 new messages