Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 240
rih5342 Avatar asked Mar 01 '17 16:03

rih5342


People also ask

Can MinGW and Cygwin coexist?

The MSYS2 and CYGWIN can be used with different operation modes: You can use them together with MinGW to build Windows-native software. You can use them together with any other compiler to build Windows-native software, even with Visual Studio.

What compiler does Cygwin use?

For source code , that uses the posix api , the cygwin-gcc compiler can be used , it provides a substantial implementation of the posix api , provided by the cygwin1. dll library . cygwin-gcc , can also be used to compile source code , which uses the windows api . In both cases , the cygwin1.


1 Answers

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.

like image 184
Iguananaut Avatar answered Oct 07 '22 12:10

Iguananaut