-
Notifications
You must be signed in to change notification settings - Fork 262
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
Fix dll builds under mingw-w64 #2290
base: main
Are you sure you want to change the base?
Conversation
I am surprised at this. We routinely test our code using mingw as a github action.
|
Additional point: we will not get rid of the EXTERNL because it is the macro that allows us to add necessary __declspec declarations for visual studio. |
Hi @DennisHeimbigner , I was using |
On the |
We also EXTERNL some functions so our unit-tests can access them, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaving a review since we have adopted the 'review required' workflow, but the comment thread from Dennis is spot on, insofar as we need to retain EXTERNL
but can modify the definition as he described.
Relevant definition appears to be here: Lines 544 to 556 in 12a9083
Perhaps cmake is setting DLL_NETCDF when autotools does not?
There's similar bits in Out of curiousity, where does autotools set Lines 106 to 110 in 5ccb71d
Does the CMake build succeed if those lines are removed from config.h.cmake.in ? It looks like that would trigger gcc's auto-export-everything behavior.
Also, CMake on MinGW is unsupported, and the Autotools CI job explicitly requests that the linker mark every function |
Building the netcdf dll and related executables under mingw-w64 (with
cmake
) fails due to an undefined reference to `NC4_show_metadata'. The code contains a workaround for the MS C compiler, and this can be extended to gcc in mingw-w64.After that, the build fails again due to undefined references to functions in tst_utils.h, which are declared as
dllimport
when they should beextern
.After fixing tst_utils.h, the build completes and all except 4 tests pass. The failed tests are:
82 - nc_test4_tst_filter (Failed)
83 - nc_test4_tst_specific_filters (Failed)
222 - nczarr_test_run_filter (Failed)
223 - nczarr_test_run_specific_filters (Failed)
All of the failed tests relate to filters, which are not being built under mingw-w64. I think this is because
libdl
is not available by default on mingw-w64, although it can be installed as an optional package. These tests should probably be disabled if the filters are not built.