Aria2 Win32 (MinGW) port Ross Smith (http://smithii.com) 21-Sep-09 Note: an older version of aria2 is also available via Cygwin's standard setup program. Version used: aria2-1.6.0 MinGW (Windows): MinGW 5.1.3 / gcc 4.3.0 (GCC TDM-3 for MinGW) MSYS 1.2.0 C-Ares 1.6.0 LibXML 2.7.3 OpenSSL 0.9.8h (I'm unable to compile 0.9.8k at the moment) SQLite3 3.6.16 Zlib 1.2.3 1. Install ActivePerl > wget http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi > msiexec /i ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi 2. Install Cygwin > wget http://www.cygwin.com/setup.exe > cacls setup.exe /C /E /G "%USERNAME%":F > setup.exe (install gcc* + auto* + sftp packages) 3. Install MingGW > wget http://smithii.com/files/get_mingw.cmd > cacls setup.exe /C /E /G "%USERNAME%":F > get_mingw.cmd 4. Build OpenSSL for MinGW using Cygwin: (I'm currently not able to build OpenSSL in MinGW) > path=c:\cygwin\bin;%path% > c:\cygwin\bin\bash --login -i $ wget http://smithii.com/files/openssl-mingw.mak $ make -f openssl-mingw.mak $ make -f openssl-mingw.mak install $ cp -prv /usr/local/ssl/* /c/msys/1.0/local $ exit 5. Build C-Ares/CppUnit/LibXML/SQLite3 and Aria2 in MinGW: > path=c:\perl\bin;c:\msys\1.0\bin;c:\mingw\bin;%path% > c:\msys\1.0\bin\sh --login -i $ wget http://smithii.com/files/c-ares.mak $ wget http://smithii.com/files/cppunit.mak $ wget http://smithii.com/files/libxml2.mak $ wget http://smithii.com/files/sqlite3.mak $ wget http://smithii.com/files/zlib.mak $ make -f c-ares.mak $ make -f c-ares.mak install $ make -f cppunit.mak $ make -f cppunit.mak install $ make -f libxml2.mak $ make -f libxml2.mak install $ make -f sqlite3.mak $ make -f sqlite3.mak install $ make -f zlib.mak $ make -f zlib.mak install $ make -f aria2.mak $ pushd aria2-1.5.2/src $ export PATH=/usr/local/bin:/mingw/bin:$PATH $ # aria2c.exe needs /usr/local/bin/libxml2-2.dll and /mingw/bin/pthreadGC2.dll $ ./aria2c.exe --version $ popd 6. Build and run unit tests (optional): $ make -f aria2.mak test $ pushd aria2-1.5.2/test $ export PATH=/usr/local/bin:/mingw/bin:$PATH $ # aria2c.exe needs /usr/local/bin/libxml2-2.dll and /mingw/bin/pthreadGC2.dll $ ./aria2c.exe $ popd $ exit 7. Build the distribution (e.g., aria2-1.5.2-win32-mingw.zip) (optional): 7a. Install GetGnuWin32 (needed for zip command) > wget http://superb-west.dl.sourceforge.net/sourceforge/getgnuwin32/GetGnuWin32-0.6.21.exe > cacls setup.exe /C /E /G "%USERNAME%":F > GetGnuWin32-0.6.21.exe 7b. Execute: > path=%path%;C:\Progra~1\GnuWin32\bin > c:\msys\1.0\bin\sh --login -i $ make -f aria2.mak dist $ exit 8. Upload to SourgeForge (requires Cygwin's sftp program): > path=%path%;C:\Progra~1\GnuWin32\bin > c:\msys\1.0\bin\sh --login -i $ make -f aria2.mak upload $ exit ****************************************************************************** OLD NOTES ****************************************************************************** Debian MinGW Cross-compiler (untried since 0.11.4): mingw32 3.4.5.20060117.1.dfsg-2 (gcc 3.4.5) mingw32-binutils 2.16.91-20060119.1-1 mingw32-runtime 3.9-4 C-Ares 1.5.2 LibXML 2.6.29 OpenSSL 0.9.8e Cygwin (Windows) (untried since 0.11.4): Cygwin 1.5.24 / gcc 3.4.4 LibXML 2.6.26 OpenSSL 0.9.8e Patches applied: aria2-0.11.4-mingw-cross-compile.patch (this patch is required when using the Debain MinGW Cross-compiler) To build Aria2 using Debain MinGW Cross-compiler: (First build openssl using Windows MinGW described below) On your Windows box: c:> cd c:\msys\local\lib c:> scp -p \ libtasn1.dll.a \ libtasn1.la \ libtasn1.a \ libz.a \ libssl32.a \ libeay32.a \ libssl.a \ libcrypto.a \ root@debianbox:/usr/i586-mingw32msvc/lib c:> cd c:\msys\local\include c:> scp -pr openssl root@debianbox:/usr/i586-mingw32msvc/include On your debian box: $ wget http://smithii.com/files/c-ares.mak $ wget http://smithii.com/files/cppunit.mak $ wget http://smithii.com/files/libxml2.mak $ wget http://smithii.com/files/aria2.mak $ make -f c-ares.mak install $ make -f cppunit.mak install $ make -f libxml2.mak install $ make -f aria2.mak $ make -f aria2.mak test On your Windows box: c:> pushd \\debianbox\home\ross\src\aria2-0.13.0\test z:> aria2c.exe z:> popd To build Aria2 in Cygwin: Using Cygwin's setup.exe installer, install the following packages: 1. cppunit 2. libgnutls-devel 3. libxml2-devel 4. openssl-devel > c:\cygwin\bin\bash --login -i $ wget http://smithii.com/files/c-ares.mak $ wget http://smithii.com/files/aria2.mak $ make -f c-ares.mak install $ make -f aria2.mak $ make -f aria2.mak test $ pushd aria2-0.11.4/test $ ./aria2c.exe $ popd ------------------------------------------------------------------------------ Version 0.11.4 test suite results: For MingW, All unit tests passed! For Cygwin: I haven't compiled 0.11.4 using Cygwin. ------------------------------------------------------------------------------ Version 0.11.3 test suite results: For MingW, All unit tests passed! For Cygwin: I haven't compiled 0.11.3 using Cygwin. ------------------------------------------------------------------------------ Version 0.11.2 test suite results: For MingW, All unit tests passed! For Cygwin: For Cygwin, the test suite immediately stackdumps. I haven't had time to research this yet. This most likely is due to Cygwin using gcc 3.4.4. Once Cygwin upgrades gcc to version 4.2 or higher, this problem may fix itself. ------------------------------------------------------------------------------ Version 0.11.1+1 test suite results: For Cygwin, the test suite immediately stackdumps. I haven't had time to research this yet. For Debian MingW, 3 unit tests are currently failing: ============================== UtilTest.cc:274:Assertion Test name: UtilTest::testRandomAlpha equality assertion failed - Expected: rUopvKRn - Actual : AdKqeYSu CookieParserTest.cc:34:Assertion Test name: CookieParserTest::testParse equality assertion failed - Expected: 1181473200 - Actual : 1181.5.2b+2009021100 TimeSeedCriteriaTest.cc:26:Assertion Test name: TimeSeedCriteriaTest::testEvaluate assertion failed - Expression: cri.evaluate() Failures !!! Run: 340 Failure total: 3 Failures: 3 Errors: 0 For Windows MingW, 12 unit tests are currently failing: ============================== HttpHeaderProcessorTest.cc:44:Assertion Test name: HttpHeaderProcessorTest::testUpdate1 assertion failed - Expression: proc.eoh() HttpHeaderProcessorTest.cc:54:Assertion Test name: HttpHeaderProcessorTest::testUpdate2 assertion failed - Expression: proc.eoh() HttpHeaderProcessorTest.cc:63:Assertion Test name: HttpHeaderProcessorTest::testGetPutBackDataLength assertion failed - Expression: proc.eoh() HttpHeaderProcessorTest.cc:81:Assertion Test name: HttpHeaderProcessorTest::testGetPutBackDataLength_nullChar assertion failed - Expression: proc.eoh() ##Failure Location unknown## : Error Test name: HttpHeaderProcessorTest::testGetHttpStatusHeader uncaught exception of unknown type ##Failure Location unknown## : Error Test name: HttpHeaderProcessorTest::testGetHttpStatusHeader_statusOnly uncaught exception of unknown type HttpHeaderProcessorTest.cc:197:Assertion Test name: HttpHeaderProcessorTest::testGetHeaderString equality assertion failed - Expected: HTTP/1.1 200 OK Date: Mon, 25 Jun 2007 16:04:59 GMT Server: Apache/2.2.3 (Debian) Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT ETag: "594065-23e3-50825cc0" Accept-Ranges: bytes Content-Length: 9187 Connection: close Content-Type: text/html; charset=UTF-8 - Actual : UtilTest.cc:274:Assertion Test name: UtilTest::testRandomAlpha equality assertion failed - Expected: rUopvKRn - Actual : AdKqeYSu CookieParserTest.cc:34:Assertion Test name: CookieParserTest::testParse equality assertion failed - Expected: 1181473200 - Actual : 1181.5.2b+2009021100 ByteArrayDiskWriterTest.cc:36:Assertion Test name: ByteArrayDiskWriterTest::testWriteAndRead equality assertion failed - Expected: Hello world! - Actual : ByteArrayDiskWriterTest.cc:57:Assertion Test name: ByteArrayDiskWriterTest::testWriteAndRead2 equality assertion failed - Expected: Hello world! - Actual : TimeSeedCriteriaTest.cc:26:Assertion Test name: TimeSeedCriteriaTest::testEvaluate assertion failed - Expression: cri.evaluate() Failures !!! Run: 340 Failure total: 12 Failures: 10 Errors: 2 FAIL: aria2c ============================== I researched the ByteArrayDiskWriterTest errors, and the problem appears to be in the stringstream STL class in MinGW. For example: #include #include #include using namespace std; int main() { stringstream ss (stringstream::in | stringstream::out); string msg1 = "line1\nline2"; char buf[100]; int c; memset(buf, '\0', sizeof(buf)); cout << "msg1=" << msg1 << endl; ss.seekg(0, ios_base::beg); ss.write(msg1.c_str(), msg1.size()); cout << "ss.str()=" << ss.str() << endl; ss.seekg(0, ios_base::beg); cout << "ss.str()=" << ss.str() << endl; ss.read(buf, msg1.size()); c = ss.gcount(); cout << "c=" << c << endl; cout << "ss.str()=" << ss.str() << endl; ss.clear(); cout << "ss.str()=" << ss.str() << endl; buf[c] = '\0'; cout << "buf =" << buf << endl; memset(buf, '\0', sizeof(buf)); ss.read(buf, sizeof(buf)); c = ss.gcount(); cout << "c=" << c << endl; ss.clear(); buf[c] = '\0'; cout << "buf =" << buf << endl; } The above program outputs correctly in Linux, Cygwin, and with the executable compiled using the Debian MinGW cross compiler. msg1=line1 line2 ss.str()=line1 line2 ss.str()=line1 line2 c=11 ss.str()=line1 line2 ss.str()=line1 line2 buf =line1 line2 c=0 buf = but fails in MinGW: msg1=line1 line2 ss.str()= ss.str()= c=0 ss.str()= ss.str()= buf = c=0 buf = ============================== ------------------------------------------------------------------------------ Version 0.11.0 test suite results: For MingW, 6 unit tests are currently failing: ============================== UtilTest.cc:250:Assertion Test name: UtilTest::testRandomAlpha equality assertion failed - Expected: rUopvKRn - Actual : AdKqeYSu CookieParserTest.cc:34:Assertion Test name: CookieParserTest::testParse equality assertion failed - Expected: 1181473200 - Actual : 1181.5.2b+2009021100 ByteArrayDiskWriterTest.cc:36:Assertion Test name: ByteArrayDiskWriterTest::testWriteAndRead equality assertion failed - Expected: Hello world! - Actual : ByteArrayDiskWriterTest.cc:57:Assertion Test name: ByteArrayDiskWriterTest::testWriteAndRead2 equality assertion failed - Expected: Hello world! - Actual : TimeSeedCriteriaTest.cc:26:Assertion Test name: TimeSeedCriteriaTest::testEvaluate assertion failed - Expression: cri.evaluate() DefaultBtRequestFactoryTest.cc:153:Assertion Test name: DefaultBtRequestFactoryTest::testCreateRequestMessages_onEndGame equality assertion failed - Expected: 0 - Actual : 1 ============================== For Cygwin, the test suite immediately stackdumps. I haven't had time to research this yet. For version 0.10.2+1, I was not able to compile the test suite. ------------------------------------------------------------------------------ For version 0.9.0, 3 unit tests failed using MingW build: ============================== UtilTest.cc:232:Assertion Test name: UtilTest::testRandomAlpha equality assertion failed - Expected: rUopvKRn - Actual : AdKqeYSu BitfieldManTest.cc:168:Assertion Test name: BitfieldManTest::testGetMissingIndex equality assertion failed - Expected: 80 - Actual : 0 TimeSeedCriteriaTest.cc:26:Assertion Test name: TimeSeedCriteriaTest::testEvaluate assertion failed - Expression: cri.evaluate() ============================== For version 0.9.0, 2 unit tests failed using Cygwin build: ============================== UtilTest.cc:232:Assertion Test name: UtilTest::testRandomAlpha equality assertion failed - Expected: rUopvKRn - Actual : yDYvSwiB BitfieldManTest.cc:168:Assertion Test name: BitfieldManTest::testGetMissingIndex equality assertion failed - Expected: 80 - Actual : 104 ==============================