Skip to content

NetCDF 4.9.0: undefined reference to `ncp_win32_api' on MinGW (libncpoco) #2396

@Alexander-Barth

Description

@Alexander-Barth

I tried to update the NetCDF version available to julia users.
However, netCDF 4.9.0 fails to build during cross-compilation for x86_64-w64-mingw32 with the error "undefined reference to `ncp_win32_api'" .

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

NetCDF 4.9.0

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

target x86_64-w64-mingw32 (cross compiled from Linux)
With gcc version: x86_64-w64-mingw32-gcc (GCC) 4.8.5

  • a description of the issue with the steps needed to reproduce it

Here are the steps how we compile NetCDF (https://github.com/JuliaPackaging/Yggdrasil/blob/master/N/NetCDF/common.jl#L59)

./configure --prefix=/workspace/destdir --build=x86_64-linux-musl --host=x86_64-w64-mingw32 --enable-shared --disable-static --disable-dap-remote-tests --disable-testsets
make LDFLAGS="-L/workspace/destdir/bin -lhdf5-0 -lhdf5_hl-0 -lcurl-4 -lz -no-undefined -Wl,--export-all-symbols" -j8

The build step fails with:

[22:59:58] make[2]: Entering directory '/workspace/srcdir/netcdf-c-4.9.0/liblib'           
[22:59:58] /bin/sh ../libtool  --tag=CC   --mode=compile cc -DHAVE_CONFIG_H -I. -I..  -I../include -I../include -I../oc2 -I../libnczarr  -I../libhdf5  -I../libdap2 -I
../oc -I../libdap4 -I../libncxml -I../libsrc4 -I../libnczarr -I../libncpoco -I/workspace/destdir/include  -std=c99 -fno-strict-aliasing -MT libnetcdf_la-nc_initialize
.lo -MD -MP -MF .deps/libnetcdf_la-nc_initialize.Tpo -c -o libnetcdf_la-nc_initialize.lo `test -f 'nc_initialize.c' || echo './'`nc_initialize.c
[22:59:58] libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../include -I../include -I../oc2 -I../libnczarr -I../libhdf5 -I../libdap2 -I../oc -I../libdap4 -I../libncx
ml -I../libsrc4 -I../libnczarr -I../libncpoco -I/workspace/destdir/include -std=c99 -fno-strict-aliasing -MT libnetcdf_la-nc_initialize.lo -MD -MP -MF .deps/libnetcdf
_la-nc_initialize.Tpo -c nc_initialize.c  -DDLL_EXPORT -DPIC -o .libs/libnetcdf_la-nc_initialize.o
[22:59:58] mv -f .deps/libnetcdf_la-nc_initialize.Tpo .deps/libnetcdf_la-nc_initialize.Plo                                                     
[22:59:58] /bin/sh ../libtool  --tag=CC   --mode=link cc  -std=c99 -fno-strict-aliasing -version-info 20:0:1  -L/workspace/destdir/bin -lhdf5-0 -lhdf5_hl-0 -lcurl-4 -
lz -no-undefined -Wl,--export-all-symbols -o libnetcdf.la -rpath /workspace/destdir/lib libnetcdf_la-nc_initialize.lo ../libdispatch/libnetcdf2.la ../libdispatch/libd
ispatch.la ../libsrc/libnetcdf3.la  ../libhdf5/libnchdf5.la  ../libdap2/libdap2.la ../oc2/liboc.la ../libdap4/libdap4.la ../libncxml/libncxml.la ../libsrc4/libnetcdf4
.la ../libnczarr/libnczarr.la  ../libncpoco/libncpoco.la -lm -lsz -lxml2 -lhdf5-0 -lhdf5_hl-0 -lcurl-4 -lz                             
[22:59:58] libtool: link: cc -shared  .libs/libnetcdf_la-nc_initialize.o  -Wl,--whole-archive ../libdispatch/.libs/libnetcdf2.a ../libdispatch/.libs/libdispatch.a ../
libsrc/.libs/libnetcdf3.a ../libhdf5/.libs/libnchdf5.a ../libdap2/.libs/libdap2.a ../oc2/.libs/liboc.a ../libdap4/.libs/libdap4.a ../libncxml/.libs/libncxml.a ../libs
rc4/.libs/libnetcdf4.a ../libnczarr/.libs/libnczarr.a ../libncpoco/.libs/libncpoco.a -Wl,--no-whole-archive  -L/workspace/destdir/bin -lsz -lxml2 -lhdf5-0 -lhdf5_hl-0
 -lcurl-4 -lz  -Wl,--export-all-symbols   -o .libs/libnetcdf-19.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libnetcdf.dll.a                 
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x40): undefined reference to `ncp_win32_api'
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x4e): undefined reference to `ncp_win32_api'                                                     
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x5c): undefined reference to `ncp_win32_api'
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x6a): undefined reference to `ncp_win32_api'                                                     
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x78): undefined reference to `ncp_win32_api'
[22:59:58] ../libncpoco/.libs/libncpoco.a(ncpoco.o):ncpoco.c:(.text+0x86): more undefined references to `ncp_win32_api' follow                                        
[22:59:58] /opt/x86_64-w64-mingw32/bin/../lib/gcc/x86_64-w64-mingw32/4.8.5/../../../../x86_64-w64-mingw32/bin/ld: ../libncpoco/.libs/libncpoco.a(ncpoco.o): bad reloc 
address 0x0 in section `.pdata'                                                                                                                                       
[22:59:58] collect2: error: ld returned 1 exit status
[22:59:58] make[2]: *** [Makefile:612: libnetcdf.la] Error 1                                                                                                          
[22:59:58] make[2]: Leaving directory '/workspace/srcdir/netcdf-c-4.9.0/liblib'
[22:59:58] make[1]: *** [Makefile:764: all-recursive] Error 1                                                                                                         
[22:59:58] make[1]: Leaving directory '/workspace/srcdir/netcdf-c-4.9.0'                                                                                              
[22:59:58] make: *** [Makefile:609: all] Error 2                                                                   
[22:59:58]  ---> make LDFLAGS="${LDFLAGS_MAKE}" -j${nproc}                                                                                                            
[22:59:58]  ---> make LDFLAGS="${LDFLAGS_MAKE}" -j${nproc}                                                                       
[22:59:58] Previous command exited with 2                                                                                                                             
[22:59:58] Child Process exited, exit code 2              
┌ Warning: Build failed, the following log files were generated:                                  
│   - ${WORKSPACE}/srcdir/netcdf-c-4.9.0/config.log                                        

Attached is the file config.log

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions