A Simple Guide to Let Win32 libcurl and Perl WWW::Curl Work Together
After several hours’ work, I have finally found out how to make a compiled libcurl downloaded from cURL website and the perl module WWW::Curl work together. I hope it would be useful for you. I have already installed MinGW and ActiveState Perl 5.10.
Not everyone likes to compile libcurl. It is very boring and time comsuming. Using a compiled libcurl can save some time. So I downloaded Win32 Generic libcurl compiled by Günter Knauf from http://curl.haxx.se/download.html . The link is http://www.gknw.net/mirror/curl/win32/curl-7.18.2-devel-mingw32.zip . I guess it is compiled by MinGW.
If you try to perl Makefile.PL and make, of course it would fail. So I change something in Makefile.PL.
1. Comment “requires_external_bin 'curl-config'“, that means add a “#”
before the line;
2. Comment /usr/include, /usr/local/curl/include, /usr/local/include/curl, ../../include, ../curl/include in “my @includes“;
3. Change “C:\\INCLUDE\\CURL” in “my @includes” to the directory like “E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\include“. E:\\Perldev\\downloader is the directory where you decompress the curl-7.18.2-devel-mingw32.zip to;
4. Comment “my $cflags = `curl-config --cflags`“, “my $lflags = `curl-config --libs`“, “my $libcurl_version = `curl-config --version`” and “print "version is $libcurl_version"“;
5. Add these lines to the place where step 4 does:
my $cflags = '-I"E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\include"'; my $ldflags = '-L"E:\\Perldev\\downloader\\curl-7.18.2-devel-mingw32\\lib"'; my $lflags = '-lcurl -lcurldll';
6. Comment these lines:
if (!defined($lflags)) {
$lflags="-lcurl";
# Windows version of libcurl - not widely tested, feedback welcome!
if ($^O eq 'MSWin32') {
foreach my $try (@includes) {
if (-f $try . '\lib\libcurl_imp.lib') {
$lflags = $try . '\lib\libcurl_imp.lib' unless(-f $lflags);
last;
}
}
$lflags="libcurl.lib" unless ($lflags);
}
print "Guessing your linker flags as: $lflags\n";
}
7. At the end of this file, please change “'LIBS' =>$lflags”
to “'LIBS' =>"$ldflags $lflags"“;
8. Save the file;
9. perl Makefile.PL;
10. nmake (you need nmake from Mircosoft, which can be downloaded from
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084 );
11. nmake install.
OK, it’s done.
这里不是财经博客吗?