Menu

Is there a guide to compile wimlib on windows os?

Jobcrazy
2015-03-26
2015-04-29
  • Jobcrazy

    Jobcrazy - 2015-03-26

    Thanks to your work, I compile it successfully on linux.

    But it's very difficult to compile on windows.

    I compile it with mingw(in cygwin, i686-pc-mingw32-gcc.exe),first the libxml2,then the libiconv,and then the wimlib.

    But it reports a lot of errors,and it doesn't compile the files (win32_apply.c and etc)

    So, is there any guide to compile wimlib on windows os?

     
  • synchronicity

    synchronicity - 2015-03-26

    No, there is no guide. I build the Windows release files on Linux using MinGW. See the script: tools/make-windows-release.

    You may be able to build wimlib on Windows in a Cygwin environment with MinGW. Configure with: ./configure --host=i686-w64-mingw32. You must be able to satisfy the 3rd party library dependencies (libxml2, iconv, and winpthreads). For the actual release I now build these other libraries myself and statically link them into libwim.dll, but you don't have to do it that way.

     
    • maxpat78

      maxpat78 - 2015-04-11

      ...I tried with MSYS2 and mingw64 (gcc 4.9.2), but it stopped with the following error:

      libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -std=gnu99 -fvisibility=hidden -fno-common -Wmissing-prototypes -Wstrict-prototypes -Wundef -Wno-pointer-sign -IC:/msys32/mingw32/include/libxml2 -g -O2 -MT src/libwim_la-dentry.lo -MD -MP -MF src/.deps/libwim_la-dentry.Tpo -c src/dentry.c -o src/libwim_la-dentry.o
      src/dentry.c: In function 'read_dentry':
      src/dentry.c:1243:2: error: size of unnamed array is negative
      BUILD_BUG_ON(sizeof(struct wim_dentry_on_disk) != WIM_DENTRY_DISK_SIZE);
      ^

       
      • synchronicity

        synchronicity - 2015-04-11

        It looks like the configure script didn't correctly detect the platform as MinGW, so the build isn't using the right compiler flags. What arguments did you pass to configure?

         
        • maxpat78

          maxpat78 - 2015-04-21

          ./configure --without-ntfs-3g
          (it detects build & host as "i686-pc-msys")

           
        • maxpat78

          maxpat78 - 2015-04-21

          Ok, it was necessary to pass --host=i686-w64-mingw32 to correctly enable the compiler.
          But now link pass fails with this error:

          src/.libs/libwim_la-timestamp.o: In function wim_timestamp_to_str': C:\msys32\home\maxpat78\wimlib-1.8.0/src/timestamp.c:129: undefined reference togmtime_r'
          collect2.exe: error: ld returned 1 exit status

           
          • synchronicity

            synchronicity - 2015-04-21

            Hi,

            gmtime_r() is not available natively on Windows, so I've been relying on MinGW to provide it. On my Linux system the time.h header provided by MinGW has this:

            __forceinline struct tm *__cdecl gmtime_r(const time_t *_Time, struct tm *_Tm)
            {
              return gmtime_s(_Tm, _Time) ? NULL : _Tm;
            }
            

            You said you are using MinGW as well, so you should figure out why this declaration doesn't seem to exist for you. Alternatively you could replace gmtime_r() with the Windows-specific gmtime_s() (which has flipped arguments). Note that there may be other functions with the same problem.

             
            • maxpat78

              maxpat78 - 2015-04-22

              Thanks.

              In my time.h (MSYS2+mingw64), gmtime_r gets defined only when _POSIX_THREAD_SAFE_FUNCTIONS is defined.

              So I've manually set -D_POSIX_THREAD_SAFE_FUNCTIONS in Makefile for targets timestamp.c and imagex.c

              Now the link pass succeeds, and the resulting executable seems to work fine.

               
              • synchronicity

                synchronicity - 2015-04-29

                Funnily enough, I actually encountered this same problem on Linux after an upgrade of MinGW. I'll probably change configure.ac to set _POSIX_THREAD_SAFE_FUNCTIONS in the Windows-specific build flags.

                 
            • maxpat78

              maxpat78 - 2015-04-22

              P.S.

              Starting the MSYS2 console with mingw32_shell.bat instead of msys2_shell.bat, the --host= switch isn't anymore required with the configure script.

               
  • Jobcrazy

    Jobcrazy - 2015-04-01

    Thank you, I'll have a try.

     

Log in to post a comment.