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:
g++ `Sockets-config` -o udpserver -I/usr/local/include/Sockets \
-L/usr/local/lib/ -lSockets UdpTestSocket.cpp udpserver.cpp
Of course Sockets-config returns:
-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:
#include <StdoutLog.h>
#include <SocketHandler.h>
#include "UdpTestSocket.h"
int main(int argc,char *argv[])
{
SocketHandler h;
StdoutLog log;
h.RegStdLog(&log);
UdpTestSocket s(h);
port_t port = 5353;
if (s.Bind(port, 10) == -1)
{
printf("Exiting...\n");
exit(-1);
}
else
{
printf("Ready to receive on port %d\n",port);
}
s.AddMulticastMembership("224.0.0.251");
s.SetMulticastTTL(255);
h.Add(&s);
h.Select(1,0);
while (h.GetCount())
{
h.Select(1,0);
}
}
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