MSYS2-packages icon indicating copy to clipboard operation
MSYS2-packages copied to clipboard

fatal error: sys/wait.h: No such file or directory

Open zhou0 opened this issue 6 years ago • 20 comments

D:/msys32/usr/lib/perl5/core_perl/CORE/perl.h:804:13: fatal error: sys/wait.h: No such file or directory

include <sys/wait.h>

         ^~~~~~~~~~~~

compilation terminated.

zhou0 avatar Dec 20 '17 09:12 zhou0

Can you attach the exact command line you used to compile? And ideally all the steps to reproduce and a complete log from the compilation.

My first guess would be that you don't have all of msys2-devel installed, specifically the msys2-runtime-devel package.

-- David Macek

elieux avatar Dec 20 '17 10:12 elieux

I have msys2-devel and msys2-runtime-devel installed. This error blocks a lot of Perl modules from compiling, an example looks like

Running install for module 'Unicode::UTF8' Checksum for /home/Li ZHOU/.cpan/sources/authors/id/C/CH/CHANSEN/Unicode-UTF8-0.62.tar.gz ok Configuring C/CH/CHANSEN/Unicode-UTF8-0.62.tar.gz with Makefile.PL Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Unicode::UTF8 Writing MYMETA.yml and MYMETA.json CHANSEN/Unicode-UTF8-0.62.tar.gz /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK Running make for C/CH/CHANSEN/Unicode-UTF8-0.62.tar.gz cp lib/Unicode/UTF8.pod blib/lib/Unicode/UTF8.pod cp lib/Unicode/UTF8.pm blib/lib/Unicode/UTF8.pm Running Mkbootstrap for Unicode::UTF8 () chmod 644 "UTF8.bs" "/usr/bin/perl.exe" "-Iinc" "/usr/share/perl5/core_perl/ExtUtils/xsubpp" -typemap "/usr/share/perl5/core_perl/ExtUtils/typemap" UTF8.xs > UTF8.xsc && mv UTF8.xsc UTF8.c gcc -c -I. -DPERL_USE_SAFE_PUTENV -D_GNU_SOURCE -U__STRICT_ANSI__ -march=i686 -mtune=generic -O2 -pipe -fwrapv -fno-strict-aliasing -fstack-protector-strong -DUSEIMPORTLIB -march=i686 -mtune=generic -O2 -pipe -DVERSION="0.62" -DXS_VERSION="0.62" "-I/usr/lib/perl5/core_perl/CORE" UTF8.c In file included from UTF8.xs:3:0: D:/msys32/usr/lib/perl5/core_perl/CORE/perl.h:804:13: fatal error: sys/wait.h: No such file or directory

include <sys/wait.h>

         ^~~~~~~~~~~~

compilation terminated. make: *** [Makefile:343:UTF8.o] 错误 1 CHANSEN/Unicode-UTF8-0.62.tar.gz make -- NOT OK

zhou0 avatar Dec 21 '17 04:12 zhou0

Just throwing out an idea; maybe you're using the MINGW32 shell instead of MSYS shell? The former can't find sys/foo.h because that's in /usr/include, which is normally only used in MSYS.

I learned this myself the hard way. :)

cbrt64 avatar Jan 12 '18 18:01 cbrt64

there's no sys/wait.h in windows

amaau avatar Apr 09 '18 21:04 amaau

@amaau it's provided by msys2-runtime-devel: http://quodlibet.duckdns.org/msys2/package/msys2-runtime-devel?repo=msys&variant=x86_64

mati865 avatar Apr 09 '18 21:04 mati865

@mati865 right, my mistake

amaau avatar Apr 09 '18 22:04 amaau

@mati865 when I do sudo apt-get install msys2-runtime-devel it shows "cannot locate package. When I try to install by the url by sudo add-apt-repository http://repo.msys2.org/msys/i686/msys2-runtime-devel-3.0.6-1-i686.pkg.tar.xz it shows the repository can't be authenticated

Then I open sources.list by sudo vim /etc/apt/sources.list and add one line deb [trusted=yes] http://repo.msys2.org/msys/i686/msys2-runtime-devel-3.0.6-1-i686.pkg.tar.xz jessie main I save the file, run the sudo add-apt-repository [that long url] command again, and see the error message "E: The repository 'http://repo.msys2.org/msys/i686/msys2-runtime-devel-3.0.6-1-i686.pkg.tar.xz bionic Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. W: The repository 'http://repo.msys2.org/msys/i686/msys2-runtime-devel-3.0.6-1-i686.pkg.tar.xz jessie Release' does not have a Release file. N: Data from such a rep " Then I want to use "--allow-unauthenticated" to bypass the security setting, however, apt-add-repository does not have this flag, I wonder how to install package "msys2-runtime-devel" by Ubuntu, Linux subsystem for windows?

Also, I also try directly download the package by command pacman -S msys2-runtime-devel, it says "no display possible". Are there suggest how can I use package msys2-runtime-devel?

LinshuH avatar Apr 21 '19 04:04 LinshuH

@LinshuH There are several issues here with what you're doing:

  1. You are trying to add a pacman repository to a dpkg/APT-based package manager. Of course that won't work.
  2. Even if it would work, then you're doing it wrong: You need to add the repository url to the sources.list, not a single package like you did.
  3. Why would you want to run Windows binaries directly inside the Linux subsystem on Windows? MSYS2 and MINGW are to be run directly on Windows.

Just forget about the Ubuntu subsystem and install MSYS2 directly on Windows, it is not supposed to be run inside a Linux distribution, it makes everything more complicated.

StarWolf3000 avatar Apr 21 '19 07:04 StarWolf3000

@LinshuH msys2 use pacman package manager ported from Arch Linux. Read wiki before posting such noob questions

Alexpux avatar Apr 21 '19 07:04 Alexpux

Seems like GCC under MSYS2 does not look up /usr/include:

$ gcc -H hello.c
. C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h
.. C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_stdio_config.h
... C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h
.... C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h
..... C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h
..... C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h
..... C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h
...... C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h
....... C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h
.. C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h
.. C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl
.. C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h
... C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h
. C:/msys64/mingw64/x86_64-w64-mingw32/include/math.h
.. C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h
hello.c:3:10: fatal error: sys/wait.h: No such file or directory
    3 | #include <sys/wait.h>

Adding /usr/include manually helps my toy example:

gcc -H hello.c -I/usr/include

kovalexpro avatar Aug 14 '20 07:08 kovalexpro

@kovalexpro you posted output of mingw-w64-x86_64-gcc.

mati865 avatar Aug 14 '20 07:08 mati865

@mati865 Sure, do I have any other compiler under MSYS2? Or do you mean that ming32 would work while migw64 would not? I'm trying to build cross compiler under MSYS2 now and hit same issue as reported. I would expect gcc to look under regular folders like /usr/include for build/host compilation at least.

kovalexpro avatar Aug 14 '20 08:08 kovalexpro

MSYS2 has it's own compiler set.

StarWolf3000 avatar Aug 14 '20 08:08 StarWolf3000

@kovalexpro There are 3 subsystems:

  • msys
  • mingw32
  • mingw64

Each of them have its own compiler and you cannot mix headers and libraries from different subsystems and expect things to work.

mati865 avatar Aug 14 '20 08:08 mati865

Hi, I want to install Perl XS module. XS means C language extension.

I get the same error as this topic.

$ cpan SPVM

...

C:/msys64/usr/lib/perl5/core_perl/CORE/perl.h:1003:13: fatal error: sys/wait.h: No such file or directory
 1003 | #   include <sys/wait.h>
      |             ^~~~~~~~~~~~

Strawberry Perl can install this SPVM module.

msys2 have error.

Strawberry Perl maybe don't include "sys/wait.h" in the following header

perl.h

https://github.com/Perl/perl5/blob/blead/perl.h#L1069

Enviromnet:

perl -v

This is perl 5, version 32, subversion 0 (v5.32.0) built for x86_64-msys-thread-multi
shell

MSYS2 MinGW 64-bit
$ which gcc
/mingw64/bin/gcc
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-10.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --disable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev9, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --with-boot-ldflags='-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' 'LDFLAGS_FOR_TARGET=-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high' --enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ -pipe\ -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\ -Wl,--stack,12582912'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Rev9, Built by MSYS2 project)
$ gcc -print-search-dirs
install: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/
programs: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/10.2.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/
libraries: =C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/;C:/msys64/mingw64/bin/../lib/gcc/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.2.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../x86_64-w64-mingw32/10.2.0/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/10.2.0/;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/../lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/;C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../;D:/a/_temp/msys/msys64/mingw64/x86_64-w64-mingw32/lib/

yuki-kimoto avatar Mar 11 '21 05:03 yuki-kimoto

Why can't people read?

@yuki-kimoto You are not supposed to compile msys2 stuff with mingw compiler. Install the compiler for msys2 and use the msys2 shell.

StarWolf3000 avatar Mar 11 '21 05:03 StarWolf3000

@StarWolf3000

You are not supposed to compile msys2 stuff with mingw compiler. Install the compiler for msys2 and use the msys2 shell.

OK. I understand something. Perl is UNIX/Linux things. so that must use msys2 shell.

Only use MSYS2 MinGW 64-bit shell to create Windows Native Application.

yuki-kimoto avatar Mar 11 '21 05:03 yuki-kimoto

For future reference, the reason this is happening is because the perl being used is /usr/bin/perl which is the MSYS Perl https://packages.msys2.org/package/perl. You want the MinGW64 Perl which is at /mingw64/bin/perl https://packages.msys2.org/package/mingw-w64-x86_64-perl. Install the mingw-w64-x86_64-perl package and use the MinGW64 shell.

zmughal avatar Feb 12 '22 16:02 zmughal

So, how hard is to add sys/wait.h support for the Mingw64 shell?

aullidolunar avatar Apr 30 '22 01:04 aullidolunar

You can use msys2 environment which is compatible with posix. That header file is present in /usr/include/sys/wait.h.

Biswa96 avatar Apr 30 '22 04:04 Biswa96