closed account (
3hMz8vqX)
Hi All,
I am a beginner in WINAPI C++ and I like to download files from the internet using
the URLDownloadToFile() function
I did all the syntax and stuff correctly . . .
I use Orwell Dev-C++ TDM GCC
Im using Windows 7 Ultimate 32 bit . . .
But I get the following error when I compile my project
C:\Users\user\Documents\CC++\main.o main.cpp:(.text+0x3e): undefined reference to `URLDownloadToFileA@20'
And I cannot find liburlmon.a ???
Please Please help me . . .
Thankyou everyone in advance!!!
I am a beginner in WINAPI C++ and I like to download files from the internet using
the URLDownloadToFile() function
I did all the syntax and stuff correctly . . .
I use Orwell Dev-C++ TDM GCC
Im using Windows 7 Ultimate 32 bit . . .
But I get the following error when I compile my project
C:\Users\user\Documents\CC++\main.o main.cpp:(.text+0x3e): undefined reference to `URLDownloadToFileA@20'
And I cannot find liburlmon.a ???
Please Please help me . . .
Thankyou everyone in advance!!!
Out of interest, is the header urlmon.h provided with your GCC? Or have you obtained it from elsewhere?
I have GCC 4.7.2 from the main MinGW release ( http://sourceforge.net/projects/mingw/ ) and it has neither the urlmon.h header nor the import library.
If you can't find a suitable import library, you could dynamically link instead. You only need the single function for the basic use of the URLDownloadToFile function.
Andy
PS If you want to receive progress messages while downloading a file with URLDownloadToFile, it's rather more compicated!
I have GCC 4.7.2 from the main MinGW release ( http://sourceforge.net/projects/mingw/ ) and it has neither the urlmon.h header nor the import library.
If you can't find a suitable import library, you could dynamically link instead. You only need the single function for the basic use of the URLDownloadToFile function.
Andy
PS If you want to receive progress messages while downloading a file with URLDownloadToFile, it's rather more compicated!
Last edited on Aug 3, 2013 at 5:07am
I have got a small program to link by using the libmon header and import lib from the Windows SDK (version 7.0).
But it did involve a bit of hacking, mostly to #define away all the SAL annotations littering urlmon.h. I also had to provide an empty msxml.h file and #define a few pretend types to make the compiler happy (types I would not be using, so any old definition was ok).
After that, I think dynamic linking would be both easier and rather tidier!
Andy
SAL Annotations
http://msdn.microsoft.com/en-us/library/ms235402%28v=vs.100%29.aspx
I copied urlmon.h and urlmon.lib from the Windows SDK into a directory along with:
a. main.cpp (see below)
b. an empty file named msxml.h
c. hack.h (see below)
And then built main.cpp using g++ and a regular Windows command prompt, with the MinGW tools on the path, using:
(but without wrapping; that was done to make it display a bit better here.)
There were a couple of warnings about unknown #pragma's, but other than that it built ok, to url_test.exe. And ran! (It downloads a copy of the working draft of the C++ standard to the folder C:\Test, which is assumed to exist.)
Where main.cpp is:
and hack.h is:
But it did involve a bit of hacking, mostly to #define away all the SAL annotations littering urlmon.h. I also had to provide an empty msxml.h file and #define a few pretend types to make the compiler happy (types I would not be using, so any old definition was ok).
After that, I think dynamic linking would be both easier and rather tidier!
Andy
SAL Annotations
http://msdn.microsoft.com/en-us/library/ms235402%28v=vs.100%29.aspx
I copied urlmon.h and urlmon.lib from the Windows SDK into a directory along with:
a. main.cpp (see below)
b. an empty file named msxml.h
c. hack.h (see below)
And then built main.cpp using g++ and a regular Windows command prompt, with the MinGW tools on the path, using:
g++ -ggdb -O2 -fomit-frame-pointer -std=c++11 -Wall -pedantic -U __STRICT_ANSI__ -DNDEBUG -o url_test.exe main.cpp -lwininet -luuid urlmon.lib |
(but without wrapping; that was done to make it display a bit better here.)
There were a couple of warnings about unknown #pragma's, but other than that it built ok, to url_test.exe. And ran! (It downloads a copy of the working draft of the C++ standard to the folder C:\Test, which is assumed to exist.)
Where main.cpp is:
| |
|
and hack.h is:
| |
Last edited on Aug 3, 2013 at 5:05am
And this version of main.cpp show what you need to do to receive status feedback (as it's a console app, I use the status info to update an ASCII progress bar...)
The URLDownloadToFile function appears to have been designed to work with ActiveX controls (i.e. COM objects), so that's the way the callback mechanism works. Might not be so easy to understand if you don't already know COM.
Component Object Model
http://en.wikipedia.org/wiki/Component_Object_Model
Andy
The URLDownloadToFile function appears to have been designed to work with ActiveX controls (i.e. COM objects), so that's the way the callback mechanism works. Might not be so easy to understand if you don't already know COM.
Component Object Model
http://en.wikipedia.org/wiki/Component_Object_Model
Andy
C:\cplusplus\url_tool>url_test.exe Downloading : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf To local file : C:\Test\n3337.pdf Finding resource... Connecting... Sending request... Mime type available Begin download Cache filename available 100% [====================] End download Downloaded OK |
| |
|
Last edited on Aug 3, 2013 at 5:05am
Topic archived. No new replies allowed.