【问题标题】:Learning how to use Configure && Make with MinGW学习如何在 MinGW 中使用 Configure && Make
【发布时间】:2020-02-06 18:48:19
【问题描述】:

我经常在工作中使用Rufus,并且我想将代码提交给项目以表示感谢。问题是这是我从事的第一个开源 C++ 项目。在 README.md pbatard 的 Compile 部分中提到可以使用“Configure && Make”。我发现我可以在 C:\MinGW\msys\1.0 中使用 msys.bat 来运行这些命令(在 Windows 中)。虽然我收到以下错误:

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

是我在 MinGW 上做错了什么,还是代码有问题?我原以为这会奏效,因为我已经克隆了Release 3.8

非常感谢!

【问题讨论】:

  • 试试 MSYS2 而不是 MSYS1。
  • 这与您的问题完全无关,但请注意它是configure &amp;&amp; make 而不是Configure &amp;&amp; Make。在文件系统不区分大小写的 Windows 上,后者可以工作,但在区分大小写的系统(例如 GNU/Linux)上,它有很大的不同......注意命令的大小写并使用它们很重要记录在案。

标签: c++ makefile mingw configure


【解决方案1】:

我也尝试使用 msys1 编译 Rufus,但最终遇到了完全相同的问题。

更改为 MSYS2 后,一切正常。以下是我采取的步骤:

  1. 根据官方页面安装MSYS2:

    https://www.msys2.org/
    
  2. 将项目复制/移动到您的 MSYS2 主目录:

    C:\msys64\home\<USER>
    
  3. 在 MSYS2 shell 中,安装编译工具:

    $ pacman -S --needed base-devel mingw-w64-x86_64-toolchain
    
  4. 在 MINGW64 shell 中,运行 configuremake

    $ autoreconf -f -i
    $ configure
    $ make
    

就我而言,我遇到了与函数 popcnt8() 相关的编译错误,该函数是静态的并且具有多个定义。解决它的一种方法是在文件rufus.h 中注释掉静态定义。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    相关资源
    最近更新 更多