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

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

Closed
Alexander-Barth opened this issue Aug 2, 2022 · 5 comments · Fixed by #2529
Closed

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

Alexander-Barth opened this issue Aug 2, 2022 · 5 comments · Fixed by #2529
Assignees
Milestone

Comments

@Alexander-Barth
Copy link
Contributor

Alexander-Barth commented Aug 2, 2022

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

@WardF WardF self-assigned this Aug 2, 2022
@WardF WardF added this to the 4.9.1 milestone Aug 2, 2022
@WardF
Copy link
Member

WardF commented Aug 2, 2022

With the 4.6.0 Fortran release out the door, I am pivoting back to this and other issues we're seeing with the 4.9.0 release. I'll see if I can get this figured out and fixed, I want the release cycle for 4.9.1 to be a very short one.

@Alexander-Barth
Copy link
Contributor Author

Would it be possible to enable plugins in the MinGW CI tests? And possibly also byte range support?

https://github.com/Unidata/netcdf-c/blob/main/.github/workflows/run_tests_win_mingw.yml#L38

@WardF
Copy link
Member

WardF commented Aug 18, 2022

I don't recall why they are disabled to begin with, so let's start by taking a look at what happens if we turn them on.

@WardF
Copy link
Member

WardF commented Aug 19, 2022

@Alexander-Barth I'm curious, do you run into issues when trying to enable plugins or byterange? I am struggling to get things working, even just with the byterange, in a fresh MSYS2/MinGW64 environment. Starting with byterange, I've been able to eventually get things to compile using pkg-config libcurl --libs and pkg-config libcurl --cflags, but I then observe really odd crashes when I try to use any of the resultant executables. I confess this isn't my usual test/work environment, and if I am making a mistake that's easy to fix, I'd be glad to know about it. I'm able to replicate what's in the MinGW GitHub actions workflow script successfully, no problem.

@DWesl
Copy link
Contributor

DWesl commented Aug 20, 2022

I have plugins building with Autotools here, but hadn't tried byterange. I'm waiting on test results to see what happens. (EDIT: enabling byterange and DAP on MinGW autotools build passes)

I think the big thing with MinGW plugins is that LDADD only works for PROGRAMS targets, not LTLIBRARIES targets; you need to add libnetcdf.la to each program's _LIBADD variable (programs use LDADD, libraries use LIBADD)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants