Skip to content

Link error when compiling NCZhdf5filters.o on MinGW64 with netCDF 4.9.0 #2468

@Alexander-Barth

Description

@Alexander-Barth

I am still trying to update NetCDF for Julia users on Windows. In this test, I tried native compilation on Windows (using the MinGW64 toolchain from MSYS2).

NetCDF is configured as:

./configure --disable-testsets  --enable-shared  --disable-static  --disable-dap-remote-tests
make LDFLAGS=" -no-undefined -Wl,--export-all-symbols"

The MinGW64 compiler version is:

$ gcc --version
gcc.exe (Rev2, Built by MSYS2 project) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The full error message is:

make[3]: Entering directory '/home/Alexander Barth/netcdf-c-2/plugins'
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -fno-strict-aliasing   -module -avoid-version -shared -export-dynamic -rpath /home/Alexander Barth/netcdf-c-2/plugins -no-undefined -no-undefined -Wl,--export-all-symbols -o lib__nczhdf5filters.la -rpath /home/Alexander Barth/netcdf-c-2/plugins/plugindir NCZhdf5filters.lo  -lhdf5_hl -lhdf5 -lm -lz -lsz -lbz2 -lzstd -lxml2 -lcurl
libtool: link: rm -fr  .libs/lib__nczhdf5filters.dll.a
libtool: link: gcc -shared  .libs/NCZhdf5filters.o   -lhdf5_hl -lhdf5 -lz -lsz -lbz2 -lzstd -lxml2 -lcurl  -Wl,--export-all-symbols   -o .libs/lib__nczhdf5filters.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/lib__nczhdf5filters.dll.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x1a24): undefined reference to `nc_inq_var'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x1a5a): undefined reference to `nc_inq_type'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x2350): undefined reference to `nc_inq_var'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x2386): undefined reference to `nc_inq_type'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x2423): undefined reference to `nc_inq_dimlen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x245a): undefined reference to `nc_inq_var_chunking'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/NCZhdf5filters.o:NCZhdf5filters:(.text+0x24ee): undefined reference to `nc_inq_var_endian'
collect2.exe: error: ld returned 1 exit status
make[3]: *** [Makefile:872: lib__nczhdf5filters.la] Error 1
make[3]: Leaving directory '/home/Alexander Barth/netcdf-c-2/plugins'
make[2]: *** [Makefile:731: all] Error 2
make[2]: Leaving directory '/home/Alexander Barth/netcdf-c-2/plugins'
make[1]: *** [Makefile:764: all-recursive] Error 1
make[1]: Leaving directory '/home/Alexander Barth/netcdf-c-2'
make: *** [Makefile:609: all] Error 2

These steps worked when compiling NetCDF 4.8.1 on the same machine.

It might be related to the LDFLAGS passed to make, which is also used here:
https://github.com/Unidata/netcdf-c/blob/main/.github/workflows/run_tests_win_mingw.yml#L49

Any help would be greatly appreciated!

Maybe this is related:
#2419

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions