undefined reference errors when using C++ Sockets Library

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 3
Reputation: xplst is an unknown quantity at this point 
Solved Threads: 0
xplst xplst is offline Offline
Newbie Poster

undefined reference errors when using C++ Sockets Library

 
0
  #1
Nov 15th, 2004
I've just downloaded the C++ sockets library from www.alhem.net/Sockets, but I can't get my programs to link -- I get a lot of "undefined reference"s.... I'm using g++ version 3.3.3. on Fedora Core 2 (kernel version 2.6.5-1.358).
I can get the programs to compile (using the -c flag to g++), but any attempt to link results in the error below. My program is a verbatim copy from the tutorial on the site.
It appears that (some of) the functions for the SocketHandler and TcpSocket classes are not implemented, but I've checked, and they're there!
I'll really appreciate any help anyone can give.

Here's the compiler command I use:

g++ -L/usr/local/lib -I/usr/local/include/Sockets -o sock_test sock_test.cpp

If I use the -c flag to that command, I get no errors, meaning that I can compile, but the linker can't find the functions it's complaining about, right? I wonder if I missed something while downloading?

Please help!!

MT

  1. /*************************************
  2.  ***** Here's the code *************
  3.  *************************************/
  4. #include <TcpSocket.h>
  5. #include <SocketHandler.h>
  6.  
  7. class DisplaySocket : public TcpSocket {
  8. public:
  9. DisplaySocket(SocketHandler&);
  10. void OnRead();
  11. };
  12.  
  13. DisplaySocket::DisplaySocket(SocketHandler& h) : TcpSocket(h) {}
  14.  
  15. #define RSIZE 1024
  16.  
  17. void DisplaySocket::OnRead() {
  18.  
  19. TcpSocket::OnRead();
  20. size_t n = ibuf.GetLength();
  21. if (n > 0) {
  22. char tmp[RSIZE];
  23.  
  24. n = (n > RSIZE) ? RSIZE : n;
  25. ibuf.Read(tmp, n);
  26. printf("Read %d bytes:\n", n);
  27. for (size_t i = 0; i < n; i++) {
  28. printf("%c", isprint(tmp[i]) ? tmp[i] : '.');
  29. }
  30. printf ("\n");
  31. }
  32. }
  33.  
  34. int main() {
  35. SocketHandler h;
  36. DisplaySocket *p = new DisplaySocket(h);
  37.  
  38. p->SetDeleteByHandler();
  39. p->Open("localhost", 9002);
  40. h.Add(p);
  41. h.Select(1, 0);
  42. while (h.GetCount()) {
  43. h.Select(1, 0);
  44. }
  45. }

/*************************************
***** And here's the error output ***
*************************************/

/tmp/ccbnbrB1.o(.text+0x10): In function `DisplaySocket::DisplaySocket[not-in-charge](SocketHandler&)':
: undefined reference to `TcpSocket::TcpSocket[not-in-charge](SocketHandler&)'
/tmp/ccbnbrB1.o(.text+0x32): In function `DisplaySocket::DisplaySocket[in-charge](SocketHandler&)':
: undefined reference to `TcpSocket::TcpSocket[not-in-charge](SocketHandler&)'
/tmp/ccbnbrB1.o(.text+0x54): In function `DisplaySocket::OnRead()':
: undefined reference to `TcpSocket::OnRead()'
/tmp/ccbnbrB1.o(.text+0xb7): In function `DisplaySocket::OnRead()':
: undefined reference to `CircularBuffer::Read(char*, unsigned)'
/tmp/ccbnbrB1.o(.text+0x17b): In function `main':
: undefined reference to `SocketHandler::SocketHandler[in-charge](StdLog*)'
/tmp/ccbnbrB1.o(.text+0x20e): In function `main':
: undefined reference to `Socket::SetDeleteByHandler(bool)'
/tmp/ccbnbrB1.o(.text+0x25b): In function `main':
: undefined reference to `TcpSocket::Open(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short)'
/tmp/ccbnbrB1.o(.text+0x2e7): In function `main':
: undefined reference to `SocketHandler::Add(Socket*)'
/tmp/ccbnbrB1.o(.text+0x2fd): In function `main':
: undefined reference to `SocketHandler::Select(long, long)'
/tmp/ccbnbrB1.o(.text+0x30f): In function `main':
: undefined reference to `SocketHandler::GetCount()'
/tmp/ccbnbrB1.o(.text+0x32b): In function `main':
: undefined reference to `SocketHandler::Select(long, long)'
/tmp/ccbnbrB1.o(.text+0x34b): In function `main':
: undefined reference to `SocketHandler::~SocketHandler [in-charge]()'
/tmp/ccbnbrB1.o(.text+0x371): In function `main':
: undefined reference to `SocketHandler::~SocketHandler [in-charge]()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x10): undefined reference to `Socket::Init()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x14): undefined reference to `Socket::Close()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x1c): undefined reference to `TcpSocket::OnWrite()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x20): undefined reference to `Socket::OnException()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x24): undefined reference to `Socket::OnDelete()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x28): undefined reference to `Socket::OnConnect()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x2c): undefined reference to `Socket::OnAccept()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x30): undefined reference to `TcpSocket::OnLine(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x34): undefined reference to `Socket::OnSSLInitDone()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x38): undefined reference to `Socket::OnConnectFailed()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x3c): undefined reference to `Socket::CheckConnect()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x40): undefined reference to `TcpSocket::ReadLine()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x44): undefined reference to `Socket::SSLCheckConnect()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x4c): undefined reference to `Socket::GetPort()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTV13DisplaySocket+0x50): undefined reference to `TcpSocket::SendBuf(char const*, unsigned)'
/tmp/ccbnbrB1.o(.gnu.linkonce.t._ZN13DisplaySocketD1Ev+0x16): In function `DisplaySocket::~DisplaySocket [in-charge]()':
: undefined reference to `TcpSocket::~TcpSocket [not-in-charge]()'
/tmp/ccbnbrB1.o(.gnu.linkonce.t._ZN13DisplaySocketD0Ev+0x16): In function `DisplaySocket::~DisplaySocket [in-charge deleting]()':
: undefined reference to `TcpSocket::~TcpSocket [not-in-charge]()'
/tmp/ccbnbrB1.o(.gnu.linkonce.r._ZTI13DisplaySocket+0x8): undefined reference to `typeinfo for TcpSocket'
collect2: ld returned 1 exit status
Last edited by alc6379; Nov 16th, 2004 at 2:52 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: undefined reference errors when using C++ Sockets Library

 
0
  #2
Nov 15th, 2004
Try this:
  1. g++ -o sock_test sock_test.cpp -L/usr/local/lib -I/usr/local/include/Sockets
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: xplst is an unknown quantity at this point 
Solved Threads: 0
xplst xplst is offline Offline
Newbie Poster

Re: undefined reference errors when using C++ Sockets Library

 
0
  #3
Nov 15th, 2004
Originally Posted by Narue
Try this:
  1. g++ -o sock_test sock_test.cpp -L/usr/local/lib -I/usr/local/include/Sockets
Thanks, Narue. Unfortunately, I still get exactly the same error when I try your suggestion.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: undefined reference errors when using C++ Sockets Library

 
0
  #4
Nov 16th, 2004
>I still get exactly the same error when I try your suggestion.
It was worth a shot. Have you tried linking directly with the library (using the -l<lib> switch)?
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: undefined reference errors when using C++ Sockets Library

 
0
  #5
Nov 16th, 2004
Are you sure the library is built for your compiler?
You might have to build it from source first if it was compiled against another compiler (version).
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: xplst is an unknown quantity at this point 
Solved Threads: 0
xplst xplst is offline Offline
Newbie Poster

Re: undefined reference errors when using C++ Sockets Library

 
0
  #6
Nov 16th, 2004
Thanks again. Yes, you're right. I eventually had to link directly against my library, and also the pthread library:

... -lSockets -lpthread

Problem now sorted.

Cheers.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 1
Reputation: dcode is an unknown quantity at this point 
Solved Threads: 0
dcode dcode is offline Offline
Newbie Poster

Re: undefined reference errors when using C++ Sockets Library

 
-1
  #7
Nov 29th, 2004
I'm having similar issues, but including the lib explicitly doesn't fix it. I'm using Sockets 1.7.1 with the following g++ line:

  1. g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets \
  2. -L/usr/local/lib/ -lSockets UdpTestSocket.cpp udpserver.cpp

Of course Sockets-config returns:
  1. -D_VERSION='"1.7.1"' -DLINUX -DHAVE_OPENSSL
I took udpserver.cpp from the tutorial on the C++ Sockets homepage and modified it just a little. Here's what I'm compiling this:

  1. #include <StdoutLog.h>
  2. #include <SocketHandler.h>
  3.  
  4. #include "UdpTestSocket.h"
  5.  
  6.  
  7. int main(int argc,char *argv[])
  8. {
  9. SocketHandler h;
  10. StdoutLog log;
  11. h.RegStdLog(&log);
  12. UdpTestSocket s(h);
  13. port_t port = 5353;
  14.  
  15. if (s.Bind(port, 10) == -1)
  16. {
  17. printf("Exiting...\n");
  18. exit(-1);
  19. }
  20. else
  21. {
  22. printf("Ready to receive on port %d\n",port);
  23. }
  24. s.AddMulticastMembership("224.0.0.251");
  25. s.SetMulticastTTL(255);
  26. h.Add(&s);
  27. h.Select(1,0);
  28. while (h.GetCount())
  29. {
  30. h.Select(1,0);
  31. }
  32.  
  33. }

I'm compiling on GNU/Linux using GCC 3.3.4. I compiled this same code on my Powerbook running OS X (10.3.6) using GCC 3.3 by Apple. I had similar problems under OS X, for some reason I had to run ranlib on the library again and it worked fine. Also, I can compile the same on the Linux box to object files, it just doesn't link. This is obvious from the error ouput below.

The exact output is below.

Thanks

bash-2.05b$ g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets -L/usr/local/lib/ -lSockets UdpTestSocket.cpp udpserver.cpp
/tmp/ccVwaqcS.o(.text+0x1c): In function `UdpTestSocket::UdpTestSocket(SocketHandler&)':
: undefined reference to `UdpSocket::UdpSocket(SocketHandler&, unsigned int)'
/tmp/ccVwaqcS.o(.text+0x48): In function `UdpTestSocket::UdpTestSocket(SocketHandler&)':
: undefined reference to `UdpSocket::UdpSocket(SocketHandler&, unsigned int)'
/tmp/ccVwaqcS.o(.text+0xc2): In function `UdpTestSocket::OnRawData(char const*,unsigned int, sockaddr*, unsigned int)':
: undefined reference to `Socket::l2ip(unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
/tmp/ccVwaqcS.o(.text+0x1f4): In function `UdpTestSocket::OnRawData(char const*, unsigned int, sockaddr*, unsigned int)':
: undefined reference to `Socket::l2ip(in6_addr const&, std::basic_string<char,std::char_traits<char>, std::allocator<char> >&, bool)'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x10): undefined reference to `Socket::Init()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x14): undefined reference to `Socket::Close()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x18): undefined reference to `UdpSocket::OnRead()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x1c): undefined reference to `Socket::OnWrite()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x20): undefined reference to `Socket::OnException()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x24): undefined reference to `Socket::OnDelete()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x28): undefined reference to `Socket::OnConnect()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x2c): undefined reference to `Socket::OnAccept()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x30): undefined reference to `Socket::OnLine(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x34): undefined reference to `Socket::OnSSLInitDone()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x38): undefined reference to `Socket::OnConnectFailed()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x3c): undefined reference to `Socket::CheckConnect()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x40): undefined reference to `Socket::ReadLine()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x44): undefined reference to `Socket:SLCheckConnect()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x4c): undefined reference to `Socket::GetPort()'
/tmp/ccVwaqcS.o(.gnu.linkonce.t._ZN13UdpTestSocketD1Ev+0x16): In function `UdpTestSocket::~UdpTestSocket()':
: undefined reference to `UdpSocket::~UdpSocket()'
/tmp/ccVwaqcS.o(.gnu.linkonce.t._ZN13UdpTestSocketD0Ev+0x16): In function `UdpTestSocket::~UdpTestSocket()':
: undefined reference to `UdpSocket::~UdpSocket()'
/tmp/ccVwaqcS.o(.gnu.linkonce.r._ZTI13UdpTestSocket+0x8): undefined reference to `typeinfo for UdpSocket'
/tmp/ccpbIqWq.o(.text+0x26): In function `main':
: undefined reference to `SocketHandler:ocketHandler(StdLog*)'
/tmp/ccpbIqWq.o(.text+0x4c): In function `main':
: undefined reference to `SocketHandler::RegStdLog(StdLog*)'
/tmp/ccpbIqWq.o(.text+0x8d): In function `main':
: undefined reference to `UdpSocket::Bind(unsigned short&, int)'
/tmp/ccpbIqWq.o(.text+0x153): In function `main':
: undefined reference to `UdpSocket::AddMulticastMembership(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/tmp/ccpbIqWq.o(.text+0x22e): In function `main':
: undefined reference to `UdpSocket:etMulticastTTL(int)'
/tmp/ccpbIqWq.o(.text+0x246): In function `main':
: undefined reference to `SocketHandler::Add(Socket*)'
/tmp/ccpbIqWq.o(.text+0x264): In function `main':
: undefined reference to `SocketHandler:elect(long, long)'
/tmp/ccpbIqWq.o(.text+0x272): In function `main':
: undefined reference to `SocketHandler::GetCount()'
/tmp/ccpbIqWq.o(.text+0x296): In function `main':
: undefined reference to `SocketHandler:elect(long, long)'
/tmp/ccpbIqWq.o(.text+0x2e4): In function `main':
: undefined reference to `SocketHandler::~SocketHandler()'
/tmp/ccpbIqWq.o(.text+0x306): In function `main':
: undefined reference to `SocketHandler::~SocketHandler()'
/tmp/ccpbIqWq.o(.gnu.linkonce.t._ZN9StdoutLogC1Ev+0x16): In function `StdoutLog:tdoutLog()':
: undefined reference to `vtable for StdoutLog'
collect2: ld returned 1 exit status
bash-2.05b$ g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets -L/usr/local/lib/ -lSockets UdpTestSocket.cpp udpserver.cpp
/tmp/ccl6Rgot.o(.text+0x1c): In function `UdpTestSocket::UdpTestSocket(SocketHandler&)':
: undefined reference to `UdpSocket::UdpSocket(SocketHandler&, unsigned int)'
/tmp/ccl6Rgot.o(.text+0x48): In function `UdpTestSocket::UdpTestSocket(SocketHandler&)':
: undefined reference to `UdpSocket::UdpSocket(SocketHandler&, unsigned int)'
/tmp/ccl6Rgot.o(.text+0xc2): In function `UdpTestSocket::OnRawData(char const*,unsigned int, sockaddr*, unsigned int)':
: undefined reference to `Socket::l2ip(unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
/tmp/ccl6Rgot.o(.text+0x1f4): In function `UdpTestSocket::OnRawData(char const*, unsigned int, sockaddr*, unsigned int)':
: undefined reference to `Socket::l2ip(in6_addr const&, std::basic_string<char,std::char_traits<char>, std::allocator<char> >&, bool)'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x10): undefined reference to `Socket::Init()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x14): undefined reference to `Socket::Close()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x18): undefined reference to `UdpSocket::OnRead()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x1c): undefined reference to `Socket::OnWrite()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x20): undefined reference to `Socket::OnException()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x24): undefined reference to `Socket::OnDelete()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x28): undefined reference to `Socket::OnConnect()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x2c): undefined reference to `Socket::OnAccept()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x30): undefined reference to `Socket::OnLine(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x34): undefined reference to `Socket::OnSSLInitDone()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x38): undefined reference to `Socket::OnConnectFailed()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x3c): undefined reference to `Socket::CheckConnect()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x40): undefined reference to `Socket::ReadLine()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x44): undefined reference to `Socket:SLCheckConnect()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTV13UdpTestSocket+0x4c): undefined reference to `Socket::GetPort()'
/tmp/ccl6Rgot.o(.gnu.linkonce.t._ZN13UdpTestSocketD1Ev+0x16): In function `UdpTestSocket::~UdpTestSocket()':
: undefined reference to `UdpSocket::~UdpSocket()'
/tmp/ccl6Rgot.o(.gnu.linkonce.t._ZN13UdpTestSocketD0Ev+0x16): In function `UdpTestSocket::~UdpTestSocket()':
: undefined reference to `UdpSocket::~UdpSocket()'
/tmp/ccl6Rgot.o(.gnu.linkonce.r._ZTI13UdpTestSocket+0x8): undefined reference to `typeinfo for UdpSocket'
/tmp/ccADbXyN.o(.text+0x26): In function `main':
: undefined reference to `SocketHandler:ocketHandler(StdLog*)'
/tmp/ccADbXyN.o(.text+0x4c): In function `main':
: undefined reference to `SocketHandler::RegStdLog(StdLog*)'
/tmp/ccADbXyN.o(.text+0x8d): In function `main':
: undefined reference to `UdpSocket::Bind(unsigned short&, int)'
/tmp/ccADbXyN.o(.text+0x153): In function `main':
: undefined reference to `UdpSocket::AddMulticastMembership(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/tmp/ccADbXyN.o(.text+0x22e): In function `main':
: undefined reference to `UdpSocket:etMulticastTTL(int)'
/tmp/ccADbXyN.o(.text+0x246): In function `main':
: undefined reference to `SocketHandler::Add(Socket*)'
/tmp/ccADbXyN.o(.text+0x264): In function `main':
: undefined reference to `SocketHandler:elect(long, long)'
/tmp/ccADbXyN.o(.text+0x272): In function `main':
: undefined reference to `SocketHandler::GetCount()'
/tmp/ccADbXyN.o(.text+0x296): In function `main':
: undefined reference to `SocketHandler:elect(long, long)'
/tmp/ccADbXyN.o(.text+0x2e4): In function `main':
: undefined reference to `SocketHandler::~SocketHandler()'
/tmp/ccADbXyN.o(.text+0x306): In function `main':
: undefined reference to `SocketHandler::~SocketHandler()'
/tmp/ccADbXyN.o(.gnu.linkonce.t._ZN9StdoutLogC1Ev+0x16): In function `StdoutLog:tdoutLog()':
: undefined reference to `vtable for StdoutLog'
collect2: ld returned 1 exit status
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: grymse is an unknown quantity at this point 
Solved Threads: 0
grymse grymse is offline Offline
Newbie Poster

Re: undefined reference errors when using C++ Sockets Library

 
0
  #8
Feb 18th, 2005
Hi
When compiling and linking with gcc/g++ you should always enter the libs part last on your command line, like this:

g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets \
UdpTestSocket.cpp udpserver.cpp -L/usr/local/lib/ -lSockets -lpthread

I tested this right now and it works. Also note that I added -lpthread, since the library needs that.

Best regards
/ah
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: undefined reference errors when using C++ Sockets Library

 
0
  #9
Feb 18th, 2005
Originally Posted by grymse
Hi
When compiling and linking with gcc/g++ you should always enter the libs part last on your command line, like this:

g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets \
UdpTestSocket.cpp udpserver.cpp -L/usr/local/lib/ -lSockets -lpthread

/ah
It's not a little late for this?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: grymse is an unknown quantity at this point 
Solved Threads: 0
grymse grymse is offline Offline
Newbie Poster

Re: undefined reference errors when using C++ Sockets Library

 
0
  #10
Feb 18th, 2005
Originally Posted by frrossk
It's not a little late for this?
Yes. Better late than not at all.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 10953 | Replies: 9
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC