LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-08-2013, 08:05 AM   #1
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Rep: Reputation: Disabled
Add new protocol in ns


dear all,
i add new protocol (named Buddy) to ns. i create a folder named Buddy and put 3 files (Buddy.cpp, Buddy.h and Buddy_packet.h) in it.
after i run make command error below appers:
Buddy.h: packet.h no such file or directory
Buddy.h: ip.h no such file or direstory

the compiler cannot detect the header file used in Buddy.h, although all header files are existed.

can anybody help me?
 
Old 07-08-2013, 08:21 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
You have not resolve the locations of packet.h and ip.h. Find out if you have those files on your system, and where they are located. You then can edit your Makefile to add references to the directories where those files are located.

Somewhere in your Makefile should be the call to gcc, something like:
Code:
gcc -Wall $(LIB) $(INC) -c Buddy.cpp
Earlier in the file may be something defining your include paths, like:
Code:
LIB=-L/usr/lib/
INC=-I/usr/include/
Fix those lines in your Makefile to match what your environment or system requires and this should resolve these problems.

Another option is to forgo make and call gcc from the command line. You still will have to find the directories where your include files are located, but the call will look something like this:
Code:
gcc -o Buddy -I<directory> Buddy.cpp
 
1 members found this post helpful.
Old 07-08-2013, 10:36 AM   #3
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Makefile.txt
thanks for ur quick reply
i attached my makefile.
i only add Buddy/Buddy.o \ in line 336
i dont exactly know what should i add more than that.
is it possible to help me?
thanks
 
Old 07-08-2013, 10:48 AM   #4
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
# 3 .
Quote:
I only add Buddy/Buddy.o \ in line 336
Makefile.txt : Add to line 76 : -I./Buddy

Then you can run $ make
.. and Buddy.o will be compiled into the executable 'ns'.

-

Last edited by knudfl; 07-08-2013 at 10:50 AM.
 
Old 07-09-2013, 08:23 AM   #5
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
Dear, I add that line u mentioned but still have same errors
I insall the ns-allinone-2.35 in /usr/src/ns-allinone-2.35
and the Buddy folder is in /usr/src/ns-allinone-2.35/ns-2.35/Buddy
I need to compile my code, please please help me
thanx
Attached Files
File Type: txt Makefile.txt (20.3 KB, 19 views)

Last edited by s.arzandeh; 07-09-2013 at 08:27 AM. Reason: add an attachment
 
Old 07-09-2013, 08:28 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I suggest you grab a log of your make attempt and attach that to a reply so that the specific errors you're encountering can be viewed.
 
Old 07-09-2013, 08:55 AM   #7
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
thanks dear,
i'm new to linux, if u mean i'm supposed to attach the output of my make command, below is the attachment:
thanks
Attached Files
File Type: txt Make-Output.txt (3.8 KB, 20 views)
 
Old 07-09-2013, 09:13 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
The first things to resolve are to get the locations of packet.h, ip.h, timer-handler.h, agent.h, config.h, and scheduler.h known in your system. Find the directories where those files are located and add those to the include path in your Makefile. Add those paths to the section in your Makefile titled INCLUDES.
 
1 members found this post helpful.
Old 07-09-2013, 10:23 AM   #9
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
thanks dear,
i check the location of ip.h or packet.h for instance and both of them locate in /usr/src/ns-allinone-2.35/ns-2.35/common and the common folder already exists in makefile (-I./common)
so why still i have problem?
 
Old 07-09-2013, 10:30 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Below is the INCLUDE definitions from the Makefile you sent before, the path you mention is not in this Makefile. ./common is not the same as /usr/src/ns-allinone-2.35/ns-2.35/common.

Code:
INCLUDES = \
	-I.  \
	-I. \
	-I/usr/src/ns-allinone-2.35/tclcl-1.20 -I/usr/src/ns-allinone-2.35/otcl-1.14 -I/usr/src/ns-allinone-2.35/include -I/usr/src/ns-allinone-2.35/include -I/usr/src/ns-allinone-2.35/include -I/usr/include/pcap \
	-I./tcp -I./sctp -I./common -I./link -I./queue \
	-I./adc -I./apps -I./mac -I./mobile -I./trace \
	-I./routing -I./tools -I./classifier -I./mcast \
	-I./diffusion3/lib/main -I./diffusion3/lib \
	-I./diffusion3/lib/nr -I./diffusion3/ns \
	-I./diffusion3/filter_core -I./asim/ -I./qs \
	-I./diffserv -I./satellite \
	-I./wpan \
	-I./Buddy
 
1 members found this post helpful.
Old 07-09-2013, 11:29 AM   #11
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
# 5 .

Makefile(.txt) : Looks OK. Can't say what's wrong.


May be your "Buddy" code : Should be like ..

#include "packet.h"

I.e. not this : #include <packet.h>

-
 
1 members found this post helpful.
Old 07-09-2013, 12:33 PM   #12
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
# 5 .

Suggest : Run the command $ make depend
.. before $ make

( You can read in line 598-599, your Makefile, what 'make depend' does.)

-
 
Old 07-10-2013, 01:21 PM   #13
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
@rtmistler: i add the path of packet.h for instance into Makefile but still have same errors
@knudfl: after change <packet.h> to "packet.h" nothing changed also i run make depend and error below happend:
make: *** No rule to make target `Buddy/Buddy.cc', needed by `depend'. Stop.

Dears please help me. i need to complie my code.
 
Old 07-10-2013, 02:18 PM   #14
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
# 13 .

In one of every 1,000 builds of ns2 with a new protocol,
a similar <header not found> error can happen.


I never found out the real reason, but used a `workaround trick` :
Simply copy the "missing" headers to the Buddy/ folder from common/, etc. etc.

All the headers you will miss, are usually found inside ns-2.35/ .
Headers are easy to spot with the find command. $ find . -name <header>

-
 
1 members found this post helpful.
Old 07-11-2013, 11:31 AM   #15
s.arzandeh
LQ Newbie
 
Registered: Jul 2013
Posts: 23

Original Poster
Rep: Reputation: Disabled
thanks everybody
finally Buddy.o was created

Last edited by s.arzandeh; 07-12-2013 at 07:48 AM.
 
  


Reply



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 add a nam file on leach protocol khedidja Linux - Software 33 04-11-2014 01:13 PM
segment fault after add new protocol when simulate aicaicai Linux - Newbie 2 09-05-2011 07:16 AM
how can i add rtp protocol to my iptables rule of netfilter hdinn Linux - Newbie 1 07-30-2009 07:12 PM
how can i add the rtp protocol to my iptables rule hdinn Linux - Networking 1 07-29-2009 12:29 PM
how can i add new network protocol in kernel? cranium2004 Linux - Networking 1 11-16-2004 03:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:28 AM.

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