how to include htons

I

iceman

hi,
which header files do i need to include for using htons in linux
i had used
#include <netinet/in.h>


but i am still getting the error
undefined reference to `htons(unsigned short)'

cheers,
jegan
 
I

Ian Collins

iceman said:
hi,
which header files do i need to include for using htons in linux

Try a Linux group, htons isn't a standard C++ function. Your man pages
should have told you.
 
I

iceman

i have pasted the errors below


tmp/ccHz8q7d.o: In function
`AppClass::createBindingAcknowledgement(int, send_to_CPlane*, int)':
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:838:
undefined reference to `htons(unsigned short)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:853:
undefined reference to `htons(unsigned short)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:879:
undefined reference to `in6_fast_cksum(click_in6_addr const*,
click_in6_addr const*, unsigned short, unsigned char, unsigned short,
unsigned char const*, unsigned short)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:879:
undefined reference to `htons(unsigned short)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:892:
undefined reference to `htons(unsigned short)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:895:
undefined reference to `htons(unsigned short)'
/tmp/ccHz8q7d.o: In function
`AppClass::checkBothBindingCachesForHomeAddress(IP6Address)':
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to
`Vector<HA_bindingCacheEntry>::Vector(Vector<HA_bindingCacheEntry>
const&)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to
`Vector<HA_bindingCacheEntry>::Vector(Vector<HA_bindingCacheEntry>
const&)'

it s a long code so i am pasting only small parts

838 packet->click_ether_header.ether_type= htons(ETHERTYPE_IP6);

853 packet-
click_ip6_header.ip6_plen=htons(sizeof(mip6MobilityHeader)+
sizeof(mip6BindingAcknowledgementMessage));



checkBothBindingCachesForHomeAddress(const IP6Address homeAddress)
{
if(
655 checkABindingCacheForHomeAddress(homeAddress,
_HA_bindingCache)||
checkABindingCacheForHomeAddress(homeAddress,
_HA_as_CN_bindingCache))
{
return true;
}
else return false;
}


_HA_as_CN_bindingCache and
_HA_bindingCache
are defined as

Vector<HA_bindingCacheEntry> _HA_bindingCache;
Vector<HA_bindingCacheEntry> _HA_as_CN_bindingCache;




655
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:655:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/tmp/ccHz8q7d.o: In function
`AppClass::homeRegistrationFlagIsEqualToHomeRegistrationBit(IP6Address,
unsigned short)':
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:303:
undefined reference to
`Vector<HA_bindingCacheEntry>::Vector(Vector<HA_bindingCacheEntry>
const&)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:303:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:311:
undefined reference to
`Vector<HA_bindingCacheEntry>::Vector(Vector<HA_bindingCacheEntry>
const&)'
/home/jegan/Desktop/smc_5_0_0/examples/C++/EX1/AppClass.cpp:311:
undefined reference to `Vector<HA_bindingCacheEntry>::~Vector()'
/tmp/ccHz8q7d.o: In function
`AppClass::getHomeAddressOption(send_to_CPlane const*)':




the code where the errors are occuring is
 
I

Ian Collins

iceman said:
i have pasted the errors below
<lots or stuff snipped>

The code and errors you posted appear to have nothing to do with htons.
You appear to be missing either a library or an object file in your link.
 
I

iceman

<lots or stuff snipped>

The code and errors you posted appear to have nothing to do with htons.
You appear to be missing either a library or an object file in your link.

I had gone through the preprocessor output and the vector etc have
been resolved.
I just cannot put my finger on the mistake.Any clues about about how I
can go about debugging this issue?
--
 
J

Jim Langston

iceman said:
I had gone through the preprocessor output and the vector etc have
been resolved.
I just cannot put my finger on the mistake.Any clues about about how I
can go about debugging this issue?

It is not a debugging issue. You are simply not linking the object file
with what you need to link it to. check the documentation for htos and see
what library it requires.
 
I

Ian Collins

*Please* don't quote signatures.
I had gone through the preprocessor output and the vector etc have
been resolved.
I just cannot put my finger on the mistake.Any clues about about how I
can go about debugging this issue?

Find the library(s) or object file(s) that is missing from your link and
add it. As I said, check your man pages for htons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top