Error during making “xz-5.2.1” with MinGW/MSYS

会有一股神秘感。 提交于 2019-12-10 11:18:09

问题


I am trying to compile "xz-5.2.1" in MinGW/MSYS environment. I see the following errors:

#error UINT32_C is not defined and unsigned int is not 32-bit.

error: #error size_t is not 32-bit or 64-bit

I am not familiar with MinGW, could anyone shed some light on this? It looks like some macro definition are missing. Some header file missing?

ADD 1

The commands I used to compile the xz-5.2.1 are:

./configure
./make

The error screenshot:

Some background, I am following this link to compile the Tesseract-OCR library. And this is just one of the steps.

ADD 2

Based on the error message, I checked the sysdefs.h file. It contains the following content:

#ifdef HAVE_CONFIG_H
#   include <config.h>
#endif

The above make output contains the -DHAVE_CONFIG_H, so I think the system header file <config.h> should be included.

But strange enough, I searched the C:\MinGW\include, there's no such file. So I GUESS this may have caused the undefined UINT_MAX warning at line 57. And then the UINT32_C is not defined error at line 58.

But I don't know why the system header file config.h is missing and where to get it.

ADD 3

I dig a bit about the GNU autotools. And luckily enough I find that the following commands can carry on my build process: (Though I am still not very sure why it works. All I know is that it may be related to portability.)

autoheader  (this generates the config.h.in file)
./Configure  (this generates the config.h file from the config.h.in file)

And now, my build process is blocked by another issue as below:

It seems this is a known issue. And another thread has addressed it.

(I will continue update with my progress.)


回答1:


If you care for an easier way to handle this kind of dependency management or a general update on toolchain functionality, I strongly suggest switching to MSYS2 with MinGW-w64.

Both projects aim (and succeed) in bringing a better version of the original. MSYS2 comes with a large number of 3rd party libraries that you can easily install. MinGW-w64 allows for GCC with full C++11/14/... support and extended Windows API availability, along with some useful extensions and more up to date headers. You'll notice that most problems originating from system headers will have already been solved, either by the MinGW-Packages scripts below, or upstream (of either MinGW-w64 or the projects themselves).

For you specifically, I suggest the following steps:

  1. Install and update MSYS2.
  2. Open an MSYS2 command prompt (or the 32-bit or 64-bit command prompts if you plan on building 32-bit or 64-bit things) from the start menu entries. Install {32-bit,64-bit} MinGW-w64 GCC:

    pacman -S mingw-w64-{i686,x86_64}-gcc
    
  3. Install tesseract-OCR:

    pacman -S mingw-w64-{i686,x86_64}-tesseract-ocr
    

    and optionally the data files:

    pacman -S mingw-w64-tesseract-ocr-osd mingw-w64-{i686,x86_64}-tesseract-ocr-eng
    

And you're done. Of course, you can still compile the various dependencies yourself, but why bother? If you really want to, you can start from the build scripts for the packages you can install in MSYS2, which are located here:

https://github.com/Alexpux/MINGW-packages

Just open the PKGBUILD files and you can see the build steps required. Note that all these scripts assume the dependencies have been installed within MSYS2.

Also note that the installed packages and compilers are all independent of MSYS2 as you'd expect: you can use it only as a tool to keep your development tree up to date, and build from any other Windows environment.



来源:https://stackoverflow.com/questions/29960825/error-during-making-xz-5-2-1-with-mingw-msys

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!