I am getting an error that is
Socket.obj : error LNK2019: unresolved external symbol "int __cdecl calc_check(int)" (?calc_check@@YAHH@Z) referenced in function _main
This is mine socket.cpp
int main()
{
int hh=2;
int chkvalue=calc_check(hh);
}
This is mine checksum.c
#include <stdio.h> // Needed for printf()
#include <stdlib.h> // Needed for rand()
#include <windows.h>
#include<conio.h>
#include <stdint.h>
#include"Constant.h"
typedef unsigned char byte; typedef unsigned short int word16; typedef unsigned int word32;
#define BUFFER_LEN 6 // Length of buffer
extern char data[6]="CM00";
word16 check;
word16 checksum(char *addr, word32 count);
int calc_check(int w)
{
word32 i;
for (i=0; i<BUFFER_LEN; i++)
{
data[i]=(byte) rand();
}
check = checksum(data, BUFFER_LEN);
printf("checksum = %04X \n", check);
return check;
}
word16 checksum(char *addr, word32 count)
{
register word32 sum = 0;
while(count > 1)
{
sum += *((word16 *) addr)++;
count = count - 2;
}
if (count > 0)
sum = sum + *((byte *) addr);
while (sum>>16)
sum = (sum & 0xFFFF) + (sum >> 16);
return(~sum);
}
This is mine header file(constant.h) which is included in socket.cpp
int calc_check(int);