Undefined Reference: URLDownloadToFile

I'm attempting to download a webpage, and future webpages, for experiments and general study purposes, but I ran into an error that I couldn't seem to solve from generic Googling. What am I doing wrong?

I'm running Dev-C++ 5.4.2 on Windows 8, if that helps. Here's my code:

1
2
3
4
5
6
7
8
9
#include <tchar.h>
#include <urlmon.h>

#pragma comment(lib, "urlmon.lib")
int main()
{
	HRESULT hr = URLDownloadToFile ( NULL, _T("http://www.merriam-webster.com/word-of-the-day/"), _T("C:\\Users\\Konrad\\Desktop\\Website Handling\\Web.html"), 0, NULL );
	return 0;
}


And my errors after compiling:

1
2
C:\Users\Konrad\AppData\Local\Temp\ccv3jGk4.o	Test1.cpp:(.text+0x30): undefined reference to `URLDownloadToFileA'
C:\Users\Konrad\Desktop\Website Handling\collect2.exe	[Error] ld returned 1 exit status 
maybe you typed in the thing wrong...
whatever it is the file that youre including is there
but the thing you calling isnt
maybe look in the source code of the library see
what is really in there then look at other files in the same directory
I looked in the headers, and URLDownloadToFile is a function in urlmon.lib. I think this is a compiler error, but I don't know how to fix this. I did another test with this, and it came up with the same error:

test.cpp
1
2
3
4
5
6
#include "test.h"

int main()
{
	TestClass::TestPubFunc();
}


test.h
1
2
3
4
5
6
7
class TestClass
{
private:
    static void TestPrivFunc();
public:
    static void TestPubFunc();
};


resources.cpp
1
2
3
4
5
6
7
8
9
10
11

#include "test.h"
void TestClass::TestPubFunc()
{
	
}

void TestClass::TestPrivFunc()
{
	
}


errors:
1
2
C:\Users\Konrad\AppData\Local\Temp\ccMVNM0i.o	test.cpp:(.text+0xe): undefined reference to `TestClass::TestPubFunc()'
C:\Users\Konrad\Desktop\Website Handling\collect2.exe	[Error] ld returned 1 exit status 
Last edited on
Topic archived. No new replies allowed.