Help please to write makefile with simple program that is divided into different files.
MyConnection.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include "MyConnection.h"
#include "MyString.h"
// function for working with net
int Connection::m_CreateSocket()
{
int retsocket;
if((retsocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
String str;
str.m_Error("UDP server - socket() error");
return -1;
}
return retsocket;
}
#ifndef EXPERIMENTAL_SERVER_CONNECTION
#define EXPERIMENTAL_SERVER_CONNECTION
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
class Connection
{
public:
Connection();
virtual ~Connection();
protected:
int m_fdSocket;
sockaddr_in m_serverAddress;
int m_CreateSocket();
};
#endif
MyString.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "MyString.h"
void String::m_Error(char *buffer)
{
printf(buffer);
}
// services function for working with strings
// print char of string to display
void String::m_PrintString(char *buffer)
{
printf(buffer);
}
the easiest way to create makefiles is to use autoconf and automake utility.
you can learn it in just a couple of hour's and then creating makefiles for any number of .cpp/.h files will be child's play...