LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-01-2012, 12:34 AM   #1
monikagoyal
LQ Newbie
 
Registered: Apr 2012
Location: chandigarh(india)
Posts: 14

Rep: Reputation: Disabled
how to call c functions from tcl script


Hi

I am using ns2.35.
There are some functions in god.cc files which i want to use in my tcl script.
I dont know how to call these functions or how to link them in tcl file.
Please suggest any idea for calling these functions from tcl file.
Thanks
 
Old 05-01-2012, 01:30 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Does this help?
 
Old 05-01-2012, 01:42 AM   #3
monikagoyal
LQ Newbie
 
Registered: Apr 2012
Location: chandigarh(india)
Posts: 14

Original Poster
Rep: Reputation: Disabled
call cc functions from tcl in ns2

Thanks sir for trying to help.
But it is something different.
In ur advised link it is about some back end processing of c functions.
I want to call the functions which are already defined in god.cc file.
 
Old 05-01-2012, 03:06 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
How about this, then?
 
Old 05-01-2012, 03:21 PM   #5
monikagoyal
LQ Newbie
 
Registered: Apr 2012
Location: chandigarh(india)
Posts: 14

Original Poster
Rep: Reputation: Disabled
sir i want to use that tcl script in ns2.
bt the critcl file cannot be used in ns2.
 
Old 05-01-2012, 03:48 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Let's start at the beginning. You have a file called 'god.cc'. Considering the
extension I'll assume it to be a piece of C++ source. To use it from Tcl you'll
need to a) compile it, and b) tell Tcl about the newly compiled object/library
files existence. The 2nd link I provided does exactly that (I think).

What is your problem?


Cheers,
Tink


P.S.: This is more suitable in PROGRAMMING, so I'm moving it over there.
 
Old 05-01-2012, 11:12 PM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The most used way to use a new "god.cc" in ns2
is to compile the stuff into the binary 'ns'.

Add god.o to the Makefile.in, section OBJ_CC.
Reconfigure to get a new Makefile, and run 'make'.
( god.o can also be added to the Makefile.
Then just run 'make'.)

It is a good idea to save a copy of the original 'ns' as ns-orig.
The new ns may not be usable with the most default tcl scripts.

.
 
Old 05-01-2012, 11:39 PM   #8
monikagoyal
LQ Newbie
 
Registered: Apr 2012
Location: chandigarh(india)
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hi
I m not changing god.cc file.
The functionality that i want is already there.
I want to find whether two nodes are neighbor or not.
A function named isNeighbor is there in god.cc.
But how to call this function from my tcl script is the problem.
I hope problem is explained now.
Thanks.
 
Old 05-02-2012, 12:27 AM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
OK, you are right, god.o is already compiled into ns.
( Makefile, line 257: mac/arp.o mobile/god.o mobile/dem.o ).

Files.cc are not used in an ns2 simulation. Never.
All functions in the 451 files.cc are compiled into the binary 'ns'.

So it's just a matter of writing a tcl script with the functionality you want.

Examples : Google .. isNeighbor ns2 ..
http://old.nabble.com/How-to-calcula...d28494220.html
etc. etc.

.
 
Old 05-02-2012, 12:33 AM   #10
monikagoyal
LQ Newbie
 
Registered: Apr 2012
Location: chandigarh(india)
Posts: 14

Original Poster
Rep: Reputation: Disabled
ok
it means we cant use these functions in tcl.
We have to write that functionality in tcl itself.
Thanks sir for your guidance.
It helps a lot.
 
  


Reply

Tags
ns2-tcl, tcl-ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call functions aizkorri Programming 7 12-20-2017 01:20 PM
How to call undeclared class functions grob115 Programming 3 04-13-2012 08:42 AM
bash functions within tcl script patolfo Linux - Software 2 09-15-2011 05:31 AM
OSE system call functions to Linux Sytem Call functions required roshantraj30 Linux - General 0 06-08-2009 02:06 AM
Make libraries call their own functions Millenniumman Programming 6 06-21-2007 01:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration