Compiling gcc-7-20170212 on Windows 7-64 with cygwin, ==> wopen error
Asked Answered
P

2

7

I get the following error when compiling gcc on Windows7-64 under cygwin.

./../zlib/libz.a(libz_a-gzlib.o):gzlib.c:(.text+0x646): undefined reference to `_wopen'
./../zlib/libz.a(libz_a-gzlib.o):gzlib.c:(.text+0x646): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_wopen'
collect2: error: ld returned 1 exit status
make[3]: *** [../.././gcc/fortran/Make-lang.in:97: f951.exe] Error 1

What is wopen?

This doesn't happen with gcc-6, or with gcc-5.

Thank you.

Perrie answered 1/3, 2017 at 16:49 Comment(0)
W
6

This isn't a problem with building gcc so much, as with building zlib, of which gcc includes a vendored copy.

You may not need to build the vendored zlib if you have the zlib-devel package installed in your Cygwin. You may also need to tweak some flags to gcc's ./configure but admittedly I have not taken a close look.

That said, to build zlib on Cygwin the following patches are needed: https://github.com/Alexpux/MSYS2-packages/raw/master/zlib/1.2.11-cygwin-no-widechar.patch
https://github.com/Alexpux/MSYS2-packages/blob/master/zlib/1.2.7-zlib-symbols.patch

(Though the latter doesn't apply cleanly to 1.2.11.) This is because of an attempt to make gzopen_w work on Cygwin that isn't quite correct, since Cygwin doesn't have _wopen.

Weighin answered 26/5, 2017 at 10:2 Comment(0)
H
1

FWIW, I had the same error (with CYGWIN_NT-10.0 x86_64 and the latest zlib-1.2.11) and the following hack solved the problem:

$  cd /tmp/zlib-1.2.11    # i.e., go into main dir
$  sed -i 's/defined(_WIN32) || defined(__CYGWIN__)/defined(_WIN32)/g' gzguts.h
$  make install     # etc.: no more _wopen(...) error

Please don't flame me for lack of explanations or understanding... for myself, I was very happy to find that fix, and I hope it may help out someone else.

Hyperbaton answered 28/11, 2020 at 4:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.