简体   繁体   English

学习如何在 MinGW 中使用 Configure && Make

[英]Learning how to use Configure && Make with MinGW

I use Rufus at work quire regularly, and I would like to commit code to the project in appreciation.我经常在工作中使用Rufus ,我想向该项目提交代码以示感谢。 The problem is that this is the first open-source C++ project that I have worked on.问题是这是我从事的第一个开源 C++ 项目。 In the Compile section in README.md pbatard mentions that "Configure && Make" can be used.在README.md编译部分pbatard提到,“配置&&让”可以使用。 I found out that I can use msys.bat in C:\\MinGW\\msys\\1.0 to run those commands (in windows).我发现我可以在 C:\\MinGW\\msys\\1.0 中使用 msys.bat 来运行这些命令(在 Windows 中)。 Though I am getting the following errors:虽然我收到以下错误:

checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for ar... ar
checking for ranlib... ranlib
checking for a sed that does not truncate output... /bin/sed
checking for rm... /bin/rm
checking for strip... strip
checking for windres... windres
checking for inline... inline
enabling Large File Support (ISO support)
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/bled/Makefile
config.status: creating src/ext2fs/Makefile
config.status: creating src/libcdio/iso9660/Makefile
config.status: creating src/libcdio/udf/Makefile
config.status: creating src/libcdio/driver/Makefile
config.status: creating res/loc/Makefile
config.status: creating src/ms-sys/Makefile
config.status: creating src/syslinux/libfat/Makefile
config.status: creating src/syslinux/libinstaller/Makefile
config.status: creating src/syslinux/win/Makefile
Making all in src
make[1]: Entering directory `/c/Users/<username>/Documents/C++/rufus/src'
Making all in bled
make[2]: Entering directory `/c/Users/<username>/Documents/C++/rufus/src/bled'
  CC       libbled_a-bled.o
In file included from c:\mingw\include\stdio.h:95,
                 from ../msapi_utf8.h:23,
                 from libbb.h:24,
                 from bled.c:14:
c:\mingw\include\sys/types.h:98:22: error: conflicting types for 'off64_t'
   typedef __off64_t  off64_t;
                      ^~~~~~~
<command-line>: note: previous declaration of 'off64_t' was here
<command-line>: error: conflicting types for 'off64_t'
In file included from c:\mingw\include\stdio.h:95,
                 from ../msapi_utf8.h:23,
                 from libbb.h:24,
                 from bled.c:14:
c:\mingw\include\sys/types.h:98:22: note: previous declaration of 'off64_t' was here
   typedef __off64_t  off64_t;
                      ^~~~~~~
In file included from c:\mingw\include\io.h:56,
                 from c:\mingw\include\dos.h:64,
                 from c:\mingw\include\direct.h:53,
                 from ../msapi_utf8.h:30,
                 from libbb.h:24,
                 from bled.c:14:
c:\mingw\include\sys\types.h:98:22: error: conflicting types for 'off64_t'
   typedef __off64_t  off64_t;
                      ^~~~~~~
<command-line>: note: previous declaration of 'off64_t' was here
In file included from libbb.h:24,
                 from bled.c:14:
../msapi_utf8.h: In function 'fopenU':
../msapi_utf8.h:1005:2: error: implicit declaration of function '_wfopen_s'; did you mean '_wfopen'? [-Werror=implicit-function-declaration]
  _wfopen_s(&ret, wfilename, wmode);
  ^~~~~~~~~
  _wfopen
../msapi_utf8.h: In function '_openU':
../msapi_utf8.h:1021:2: error: implicit declaration of function '_wsopen_s'; did you mean '_wsopen'? [-Werror=implicit-function-declaration]
  _wsopen_s(&ret, wfilename, oflag, shflag, pmode);
  ^~~~~~~~~
  _wsopen
In file included from bled.c:14:
libbb.h: In function 'localtime_r':
libbb.h:198:6: error: implicit declaration of function 'localtime_s'; did you mean 'localtime_r'? [-Werror=implicit-function-declaration]
  if (localtime_s(result, timep) != 0)
      ^~~~~~~~~~~
      localtime_r
cc1.exe: some warnings being treated as errors
make[2]: *** [libbled_a-bled.o] Error 1
make[2]: Leaving directory `/c/Users/amnet_admin/Documents/C++/rufus/src/bled'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/Users/amnet_admin/Documents/C++/rufus/src'
make: *** [all-recursive] Error 1

Am I doing something wrong with MinGW, or is there something wrong with the code?是我对 MinGW 做错了什么,还是代码有问题? I would have thought this would have worked, as I haved got cloned Release 3.8我原以为这会奏效,因为我已经克隆了3.8 版

Thank you very much!非常感谢!

I also tried to compile Rufus with msys1 and ended up with the exact same problem.我还尝试使用 msys1 编译 Rufus,但最终遇到了完全相同的问题。

After changing to MSYS2 it all worked.更改为 MSYS2 后,一切正常。 Here are the steps I took:以下是我采取的步骤:

  1. Install MSYS2 according to the official page:根据官方页面安装MSYS2:

     https://www.msys2.org/
  2. Copy/Move the project to your MSYS2 home directory:将项目复制/移动到 MSYS2 主目录:

     C:\\msys64\\home\\<USER>
  3. In MSYS2 shell, install the compiler tools:在 MSYS2 shell 中,安装编译器工具:

     $ pacman -S --needed base-devel mingw-w64-x86_64-toolchain
  4. In MINGW64 shell, run configure and make :在 MINGW64 shell 中,运行configuremake

     $ autoreconf -f -i $ configure $ make

In my case I was getting compilation errors related to the function popcnt8() being static and having more than one definition.就我而言,我遇到了与popcnt8()函数是静态的并且有多个定义相关的编译错误。 One way to fix it is to just comment out the static definition in the file rufus.h .修复它的一种方法是注释掉文件rufus.h的静态定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM