[Linker error] undefined reference to `Download::download

hi, i have problem with this code to download files from url, i have search all over net, but can't figure it out, any help is appreciated.

download.h:

// Header file for downloader.

#ifndef DOWNLOAD_H
#define DOWNLOAD_H
#include <string>
#include <windows.h>
#include <wininet.h>
#include <fstream>

using namespace std;

const int MAX_ERRMSG_SIZE = 80;
const int MAX_FILENAME_SIZE = 512;
const int BUF_SIZE = 10240; // 10 KB

// Exception class for donwload errors;
class DLExc
{
private:
char err[MAX_ERRMSG_SIZE];
public:
DLExc(char *exc)
{
if(strlen(exc) < MAX_ERRMSG_SIZE)
strcpy(err, exc);
}

// Return a pointer to the error message
const char *geterr()
{
return err;
}
};


// A class for downloading files from the internet
class Download
{
private:
static bool ishttp(char *url);
static bool httpverOK(HINTERNET hIurl);
static bool getfname(char *url, char *fname);
static unsigned long openfile(char *url, bool reload, ofstream &fout);
public:
static bool download(char *url, bool reload=false, void (*update)(unsigned long, unsigned long)=NULL);
};


#endif


download.cpp:

#include <iostream>
#include <time.h>
#include <cstdlib>
#include "download.h"

using namespace std;

string dat(){
time_t rawtime;
struct tm * timeinfo;
char datum[80];
time ( &rawtime );
timeinfo=localtime(&rawtime);
strftime(datum,80,"%d%m%y",timeinfo);
return datum;
}

// This function displays the download progress as a percentage
void showprogress(unsigned long total, unsigned long part)
{
int val = (int) ((double)part / total * 100);
printf("progress: %i%%\n", val);
}

int main(int argc, char *argv[])
{
string datum=dat();
string link="http://www.hnb.hr/tecajn/f" + datum + ".dat";
int j=link.length();
char url[j+1];
strcpy(url,link.c_str());
cout << "\nDanasnji datum: " << datum << ", a url:" << link << "\n\n";
//string url[] = linkz;

bool reload = false;
if(argc==2 && !strcmp(argv[1], "reload"))
reload = true;

printf("Beginning download\n");

try
{
if(Download::download(url, reload, showprogress))
printf("Download Complete\n");
}

catch(DLExc exc)
{
printf("%s\n", exc.geterr());
printf("Download interrupted\n");
}
system("PAUSE");
return EXIT_SUCCESS;
}

"Undefined Reference" usually means you didn't give a body for a function.

Which is exactly the case here. The download function has no body.
That was your only error? I notice there is no

 
#endif 


Without that to end your if not defined at the beginning, that shouldn't be compiling with errors also but not for the error you are getting which Disch covered perfectly.
Topic archived. No new replies allowed.