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

netcdf does not build on Windows with cmake #2580

Open
joa-quim opened this issue Jan 6, 2023 · 8 comments
Open

netcdf does not build on Windows with cmake #2580

joa-quim opened this issue Jan 6, 2023 · 8 comments

Comments

@joa-quim
Copy link

joa-quim commented Jan 6, 2023

Hi, I'm a long time builder with cmake but now that tried to update my version I'm no longer able to build it.
First it asks me to have M4

-- m4 not found.
-- Ignoring C:/Windows/System32/bash.exe
CMake Error at CMakeLists.txt:1946 (MESSAGE):
  m4 is required to generate
  C:/programs/compa_libs/netcdf-c-4.9.0/libsrc/attr.c.  Please install m4 so
  that it is on the PATH and try again.

Why do I have to have M4? This is a Cmake build.
But OK, let's try it. Installed one GNU m4 for windows and first step went till the end. But compiling is all broken. It starts to say

C:\programs\compa_libs\netcdf-c-4.9.0\libdispatch\derror.c(18): error C2065: 'PACKAGE_VERSION': undeclared identifier

and if I patch that file then there are a bunch of errors like

C:\programs\compa_libs\netcdf-c-4.9.0\libdispatch\dstring.c(80): error C2065: 'uchar': undeclared identifier

Seems headers for windows are not well set.

This is with version 4.9.0 but the same happened with master.

@joa-quim
Copy link
Author

Ping

@DennisHeimbigner
Copy link
Collaborator

The problem is that somehow the file libsrc/attr.c got deleted.
CMake is trying to rebuild it, but that requires m4.
The only think I can suggest is to re-download the netcdf-c-4.9.0 source file,
verify that it contains libsrc/attr.c, and try again.

@joa-quim
Copy link
Author

joa-quim commented Feb 7, 2023

The problem is that if we use cmake -G Ninja or cmake -G NMake attr.c gets deleted and those errors follow. Doing

cmake -G "Visual Studio 17 2022" ...

and running it from VS, let it proceed a little further, but not much

14>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\stdint.h(20,35): warning C4142: 'int32_t': benign redefinition of type
14>C:\programs\compa_libs\netcdf-c-4.9.1\libsrc\pstdint.h(410,23): message : see declaration of 'int32_t'
4>C:\programs\compa_libs\netcdf-c-4.9.1\include\hdf5internal.h(76,5): error C2061: syntax error: identifier 'HDF5_OBJID_T'
4>C:\programs\compa_libs\netcdf-c-4.9.1\include\hdf5internal.h(77,1): error C2059: syntax error: '}'
4>C:\programs\compa_libs\netcdf-c-4.9.1\include\hdf5internal.h(95,5): error C2061: syntax error: identifier 'HDF5_OBJID_T'
4>C:\programs\compa_libs\netcdf-c-4.9.1\include\hdf5internal.h(100,1): error C2059: syntax error: '}'
4>C:\programs\compa_libs\netcdf-c-4.9.1\libhdf5\nc4hdf.c(99,28): error C2065: 'NC_HDF5_VAR_INFO_T': undeclared identifier
4>C:\programs\compa_libs\netcdf-c-4.9.1\libhdf5\nc4hdf.c(99,37): error C2065: 'hdf5_var': undeclared identifier

...
and tons of other errors.

@joa-quim
Copy link
Author

joa-quim commented Feb 8, 2023

And, I'm able to build netCDF (same compiler) with VCPKG that apparently applies several patches, so conclusion seems to be that cmake generated make files are broken.

@WardF
Copy link
Member

WardF commented Feb 8, 2023

Let me take a look at this; m4 has long been a requirement, even on Windows, when working with non-release code, but the tagged releases should not be trying to generate the file. In the meantime, what happens if you install gnu m4 on your path? Does that also solve the issue?

@dopplershift
Copy link
Member

@WardF Just FYI I did have to add m4 to the build dependencies for our conda-forge build of 4.9.1-rc1.

@WardF
Copy link
Member

WardF commented Feb 8, 2023

Good to know. attr.c is not kept in version control, as it's a generated file, with the exception of release branches. But clearly something changed, and I didn't notice it because I have m4 on my Windows dev system. I'll get this straightened up, but installing m4 in the meantime is probably the most straightforward work-around.

@joa-quim
Copy link
Author

joa-quim commented Feb 8, 2023

I have (like I said in 1st post) m4 installed. Tried so far 4.8.1, 4.9.0, 4.9.1 and master and same errors for all of them. Only way to build is with vcpkg but I'm not interested in that because I want to control the name of the generated DLL. Some thing that used to be possible (first cmake scripts were derived from the GMT ones were that is configurable) but I suspect was dropped meanwhile.

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