Results 1 to 7 of 7

Thread: Compiling ZPAQ on Windows with MinGW

  1. #1
    Member
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    367
    Thanks
    12
    Thanked 40 Times in 32 Posts

    Compiling ZPAQ on Windows with MinGW

    I try to compile on Win 8 64 bit with MinGW taken here http://www.mingw.org/
    Currently this include ming32-gcc/g++ version 4.8.1-4.

    But (zpaq 6.46) i got some troubles

    Code:
    C:\zpaq> g++ -O3 -s -m32 -static -DNDEBUG zpaq.cpp libzpaq.cpp divsufsort.c -Wl
    ,--large-address-aware -o zpaq
    zpaq.cpp: In function 'bool exists(std::string)':
    zpaq.cpp:1118:58: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'DWORD GetFileAttributesA(LPCSTR)'
       return GetFileAttributes(utow(filename.c_str()).c_str())
                                                              ^
    zpaq.cpp: In member function 'bool InputFile::open(const char*, const char*)':
    zpaq.cpp:1382:61: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'void* CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_A
    TTRIBUTES, DWORD, DWORD, HANDLE)'
                       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                                                                 ^
    zpaq.cpp: In member function 'bool OutputFile::open(const char*, const char*)':
    zpaq.cpp:1460:69: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'void* CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_A
    TTRIBUTES, DWORD, DWORD, HANDLE)'
                        0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
                                                                         ^
    zpaq.cpp: In member function 'void OutputFile::close(int64_t, int64_t)':
    zpaq.cpp:1571:52: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'BOOL SetFileAttributesA(LPCSTR, DWORD)'
             SetFileAttributes(filename.c_str(), attr>>8);
                                                        ^
    zpaq.cpp: In member function 'void Jidac::scandir(std::string, bool)':
    zpaq.cpp:2780:55: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'void* FindFirstFileA(LPCSTR, LPWIN32_FIND_DATAA)'
       HANDLE h=FindFirstFile(utow(t.c_str()).c_str(), &ffd);
                                                           ^
    zpaq.cpp:2797:25: error: cannot convert 'CHAR* {aka char*}' to 'const wchar_t*'
    for argument '1' to 'std::string wtou(const wchar_t*)'
         t=wtou(ffd.cFileName);
                             ^
    zpaq.cpp: In function 'void makepath(std::string&, int64_t, int64_t)':
    zpaq.cpp:4910:59: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'BOOL CreateDirectoryA(LPCSTR, LPSECURITY_ATTRIBUTES)
    '
           int ok=CreateDirectory(utow(path.c_str()).c_str(), 0);
                                                               ^
    zpaq.cpp:4940:59: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'void* CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_A
    TTRIBUTES, DWORD, DWORD, HANDLE)'
                               FILE_FLAG_BACKUP_SEMANTICS, NULL);
                                                               ^
    zpaq.cpp:4948:62: error: cannot convert 'const wchar_t*' to 'LPCSTR {aka const c
    har*}' for argument '1' to 'BOOL SetFileAttributesA(LPCSTR, DWORD)'
         SetFileAttributes(utow(filename.c_str()).c_str(), attr>>8);
                                                                  ^
    zpaq.cpp: In function 'int main()':
    zpaq.cpp:6553:58: error: cannot convert 'LPSTR {aka char*}' to 'LPCWSTR {aka con
    st wchar_t*}' for argument '1' to 'WCHAR** CommandLineToArgvW(LPCWSTR, int*)'
       LPWSTR* argw=CommandLineToArgvW(GetCommandLine(), &argc);
                                                              ^
    AFAIK MinGW (Windows) require only a properly setted "path" to BIN.

    Can someone, please, give me a ZPAQ of a complete c:\mingw (working) configuration,
    or teach how to fix this strange cast?

    Thanks to all repliers.

  2. #2
    Programmer Bulat Ziganshin's Avatar
    Join Date
    Mar 2007
    Location
    Uzbekistan
    Posts
    4,572
    Thanks
    783
    Thanked 687 Times in 372 Posts
    try -DUNICODE

  3. Thanks:

    fcorbelli (18th January 2014)

  4. #3
    Member
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    367
    Thanks
    12
    Thanked 40 Times in 32 Posts
    Quote Originally Posted by Bulat Ziganshin View Post
    Code:
    Thanks Mr. Ziganshin, this works
    C:\zpaq>  g++ -O3 -s -m32 -static -DNDEBUG -DUNICODE zpaq.cpp libzpaq.cpp divsuf
    sort.c -Wl,--large-address-aware -o zpaq
    zpaq.cpp:780:0: warning: "UNICODE" redefined [enabled by default]
     #define UNICODE
     ^
    <command-line>:0:0: note: this is the location of the previous definition
    
    C:\zpaq>
    Now I patched libzpaq.h

    Original lines 518-520

    Code:
    #include <assert.h>
    #include <stdint.h>
    #include <stdlib.h>
    Updated
    Code:
    #ifdef unix
    #else  // Can compile with mingw on Windows without -DUNICODE
    #define UNICODE
    #endif
    #include <assert.h>
    #include <stdint.h>
    #include <stdlib.h>

  5. #4
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,257
    Thanks
    307
    Thanked 797 Times in 489 Posts
    This is a problem with MinGW 4.8.1-4 from http://www.mingw.org/
    but not a problem for MinGW 4.8.1 from http://sourceforge.net/projects/ming...ds-win32/sjlj/
    The problem is the lines:

    #define UNICODE
    #include <windows.h>

    which is supposed to tell Windows to use wide strings for everything. The problem occurs if windows.h is already included from a previous header before UNICODE is defined. So I fixed it by moving the define to before the first include like this:

    #define _FILE_OFFSET_BITS 64 // In Linux make sizeof(off_t) == 8
    #define UNICODE // For Windows
    #include "libzpaq.h"
    #include "divsufsort.h"
    #include <stdio.h>
    ...

    I installed both compilers and it works on both of them. I had been using 4.8.0 from mingwbuilds before because it supports -m64 so I can create 64 bit executables in 32 bit Windows. The mingw.org version doesn't support it.

    I will put the change in the next release.

  6. #5
    Member
    Join Date
    Nov 2011
    Location
    Tunisia
    Posts
    8
    Thanks
    155
    Thanked 4 Times in 4 Posts
    Try MSYS2 with pacman (package manager) or MinGW-builds (was merged with minGW-w64). You can find last builds here http://sourceforge.net/projects/ming.../mingw-builds/

  7. Thanks:

    fcorbelli (19th January 2014)

  8. #6
    Member
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    367
    Thanks
    12
    Thanked 40 Times in 32 Posts
    Quote Originally Posted by samsat1024 View Post
    Try MSYS2 with pacman (package manager) or MinGW-builds (was merged with minGW-w64). You can find last builds here http://sourceforge.net/projects/ming.../mingw-builds/
    The last seems to work fine,even for 64 bit target. Thanks.

  9. #7
    Member
    Join Date
    Feb 2013
    Location
    ARGENTINA
    Posts
    81
    Thanks
    220
    Thanked 26 Times in 18 Posts
    Sorry, wrong post. Moved to Zpaq thread
    Last edited by surfersat; 20th January 2014 at 02:45. Reason: Sorry, wrong post. Moved to Zpaq thread

Similar Threads

  1. Compiling ZPAQ on Mac OSX 10.7.2 (Lion) gcc4.2.1 - problems!
    By z3cko in forum The Off-Topic Lounge
    Replies: 7
    Last Post: 21st December 2011, 02:28
  2. Compiling PPMd var J1 on Ubuntu
    By Piotr Tarsa in forum The Off-Topic Lounge
    Replies: 2
    Last Post: 18th December 2011, 19:17
  3. BWTS GENERAL COMPRESS in MinGW exe's
    By biject.bwts in forum Data Compression
    Replies: 18
    Last Post: 12th October 2010, 20:27
  4. GCC 4.4.1 for Windows
    By Bulat Ziganshin in forum The Off-Topic Lounge
    Replies: 1
    Last Post: 15th January 2010, 23:39
  5. can someone help me compiling paq by myself?
    By noshutdown in forum Forum Archive
    Replies: 4
    Last Post: 4th December 2007, 09:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •