Hi, got a program which I've been trying to port to Linux for a while now - and after all the changes I can think of making, the build fails with a problem related to one of my main classes. Compilation on Win32 was done with Dev-C++ 4.9.9.2 and on n*x I've been using Anjuta 1.2.4. I've posted on another site about this but so far have had absolutely no luck.
I've been at this for a couple of more days but I can't think of what could be wrong with the below sections of code, in red. The build log and those sections follow:
(PS: Before anyone thinks of this, yes I do have virtual functions present in class Sockets, thus the destructor.)
Build Log:
Code:
Building the whole Project: ConsoleL...
make -s
Making all in po
Making all in src
g++ -Wall -g -g -O2 -o consolel main.o
main.o:In function 'main':
/home/rg40/projects/ConsoleL/src/main.cc:596:undefined reference to Sockets::Sockets(Sockets const&)
/home/rg40/projects/ConsoleL/src/main.cc:681:undefined reference to Sockets::Sockets(Sockets const&)
main.o:In function '~Sockets':
../include/network.h:482:undefined reference to 'vtable for Sockets'
main.o:In function 'Sockets':
../include/network.h:405:undefined reference to 'vtable for Sockets'
collect2: ld returned 1 exit status
make[2]: *** consolel [Error 1]
make[1]: *** all-recursive [Error 1]
make: *** all-recursive-am [Error 2]
Completed ... unsuccessful
Total time taken: 11 secs
Code:
Source file:
Code:
{
HostRes hr;
Sockets sck;
#ifdef DEBUG_D
cout << "Debug (production) mode enabled." << endl;
cout << "=================================" << endl;
cout << "\n\n" << endl;
cout << "recvSocket before hr.ResolutionFunc() is " << hr.recvSocket << endl;
#endif
hr.ResolutionFunc(&ndata, sck, sck.Connection, SEND_PORT, &A, SOCK_READ);
}
. . .
if(getpeername(hr.recvSocket, (struct sockaddr *)&hr.host, &hr.tolen) == MINUS_ONE)
{
perror("getpeername");
exit(1);
}
if(!hr.recvSocket)
{
std::cout << "Connect failed." << endl;
sock.CLSocks(Main::i, Main::j, SOCK_READ);
#ifdef WIN32
WSACleanup();
#endif
return(SOCKET_INIT_FAIL);
}
sock.ConnInitialize(&ndata, sock.c, sock);
char* c = const_cast<char*>(argv[1]);
if(isdigit(argv[1][0]))
{
cout << "Connected to " << address << " \\ " << FlagVars::NameBuffer << " \n";
}
else
{
cout << "Connected to " << c << " \\ " << FlagVars::NameBuffer << " \n";
}
Include file "network.h":
Code:
class Sockets
{
private:
friend class HostRes;
char HostResAddress[32];
. . .
protected:
int IntFile;
void* File;
int* SocketConstruct;
int* SocketIntConstruct;
. . .
public:
Sockets(){SocketConstruct = new int[1024*2]; return;};
Sockets(int){SocketIntConstruct = new int[1024*2]; return;};
Sockets::Sockets(const Sockets&);
char *params;
std::string c;
. . . //rest of class is here
virtual ~Sockets(){delete [] Sockets::SocketConstruct;};
};
What could be going wrong?