Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: conflicting types for 'getopt' #1737

Closed
Alexander-Barth opened this issue May 23, 2020 · 4 comments
Closed

error: conflicting types for 'getopt' #1737

Alexander-Barth opened this issue May 23, 2020 · 4 comments

Comments

@Alexander-Barth
Copy link
Contributor

  • the version of the software with which you are encountering an issue

netcdf-c-4.7.4

  • environmental information (i.e. Operating System, compiler info, java version, python version, etc.)

Windows 10 with MSYS2 and gcc 10.1.0

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 10.1.0
  • a description of the issue with the steps needed to reproduce it

I try to compile netCDF from source but the compilation fails with the error message below.
To reproduce the error, one need to run inside the MSYS2 shell the following steps:

wget https://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-c-4.7.4.tar.gz
tar xf netcdf-c-4.7.4.tar.gz
cd netcdf-c-4.7.4/
./configure --disable-shared --disable-dap
make

The last make command fails with the error message:

libtool: link: gcc -o nccopy.exe nccopy.o nciter.o chunkspec.o utils.o dimmap.o list.o  ../liblib/.libs/libnetcdf.a -lhdf5_hl -lhdf5 -lm -lz
In file included from ncvalidator.c:79:
../include/XGetopt.h:38:5: error: conflicting types for 'getopt'
   38 | int getopt(int argc, TCHAR *argv[], TCHAR *optstring);
      |     ^~~~~~

In config.log I see the following options related to getopt.

configure:15998: checking getopt.h usability
configure:15998: gcc -c   conftest.c >&5
configure:15998: $? = 0
configure:15998: result: yes
configure:15998: checking getopt.h presence
configure:15998: gcc -E  conftest.c
configure:15998: $? = 0
configure:15998: result: yes
configure:15998: checking for getopt.h
configure:15998: result: yes

Finally the ac_cv_header_getopt_h macro it set to yes.

@DennisHeimbigner
Copy link
Collaborator

MSYS indicates your are compiling with mIngw, correct?
Try this.

  1. edit the file ncdump/ncvalidator.c
  2. on about line 76 it should say

#ifdef _WIN32

  1. Change this to

#ifdef _MSC_VER

@Alexander-Barth
Copy link
Contributor Author

Thanks a lot, I confirm that it works now!! (and you are right, I do use mingw with MSYS2.)

Pesonnally, I only use Linux, but our group tries to support people using Windows with our tools (in Fortran https://github.com/aida-alvera/DINEOF, or Julia https://github.com/Alexander-Barth/NCDatasets.jl). Obviously, this is at much smaller scale than Unidata :-) For Fortran and Julia we are required to use the mingw tool chain (as opposed to msvc). The R and Octave communites are in the same case, where they use Mingw on Windows. Would it be useful to setup some CI service to test Mingw? I can try to make some pull requests.

MSYS2 is already integrated in appveyor.com (https://www.appveyor.com/docs/windows-images-software/#mingw-msys-cygwin) but it should also be possible get installed on travis CI (https://docs.travis-ci.com/user/reference/windows/#how-do-i-use-msys2). Using a different CI service for windows has the slight advantage that it does not slow down your travis builds for your primary build platform. But there are then two places to check if it the build passes.

@DennisHeimbigner
Copy link
Collaborator

This is a problem that has cropped up and I thought we had caught all Instances.
I will make another scan for this.

@dopplershift
Copy link
Member

Fixed by #1738?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants