Hello,
I have linked a library, However, I get the following message. And can't seem to find out what the problem is. I have changed the arguments to 0 to see if that would make a difference. However, I am still getting the problem.
I also deleted the code inside CreateSocket to make it easy to finding what the problem is.
Many thanks for any advice on this problem,
Steve
steve@steve01:~/Projects/ClientApp/src$ g++ -o ../bin/client ClientApp.cpp -I ../include -L ../lib -lSocketFunctions
/tmp/cciZxGP6.o: In function `main':
ClientApp.cpp.text+0xc3): undefined reference to `CreateSocket()'
collect2: ld returned 1 exit status
My header file:
Code:
//SocketApp.h
int CreateSocket();
int SendData(int sockfd, char* buffer, int bytes);
char* SendAndReceiveData(int sockfd, char *buffer);
My library:
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include "SocketApp.h"
/* Creates a new socket and return the sock file descriptor.*/
int CreateSocket()
{
return 1;
}
The program that uses the library.
Code:
#include <iostream>
#include "SocketApp.h"
using namespace std;
int main(int argc, char** argv)
{
cout << "******* This is the client application ********" << endl;
cout << endl;
int sockfd = 0;
//Create a new socket
sockfd = CreateSocket();
cout << "sockfd: " << sockfd << endl;
return 0;
}