-
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
Incomplete library exports on Windows #554
Comments
Thank you for reporting; I will get this fixed! |
Those functions are only used for parallel I/O builds of netCDF. Did you intend to use parallel IO on Windows? That is not typical, as far as I know. So it seems like the windows DLL should not include those functions. |
Thanks for looking at it. No I didn't want to use parallel IO but it seems that netcdf-fortran has a hard dependency on those functions, see https://github.com/Unidata/netcdf-fortran/blob/78a9839366cf8cdc929da450ebba9fad941c3341/fortran/nf_nc4.f90#L61. This file is included whenever USE_NETCDF4 is enabled, see https://github.com/Unidata/netcdf-fortran/blob/78a9839366cf8cdc929da450ebba9fad941c3341/fortran/Makefile.am#L58. From what I can see, netcdf_h.h is included unconditionally in libdispatch in dvar.c which is always built. Lines 8 to 9 in 327c194
|
We currently don't officially support Fortran on Windows, which is why this hasn't received as much attention. But I should be able to address that. |
I assume you are using mingw64/fortran equivalent and not Visual Studio or some such via the MSYS shell? |
I use the mingw64 shell from the MSYS2 package. Note that the person from the linked issue used the Intel Fortran compiler on Windows and had the same problem. Make sure to build netcdf-fortran as shared library, otherwise you may not notice the undefined symbols. |
Part of the problem is a lack of access to free fortran compilers compatible with visual studio; I understand that PGI has released a community edition of their compilers, so when I get a chance I will try to get it working with that. |
OK great, I didn't know that about the PGI compiler. On their feature comparison page it says that the free version doesn't have Visual Studio integration. |
Hi @WardF, I have encountered the same issue with the installation of |
Thanks, I have mingw64 set up and will gladly take a look at this as soon as I can; it is definitely being looked at, but there are a number of issues and pull requests currently being reviewed as well. My assumption is that the functions just need to be exported as other functions have needed to be on (on Windows). @letmaik just for the sake of completion, can you share how you are building netcdf-c on Windows with cmake using MSYS2/mingw64? I work in MSYS2 already, so getting it set up won't be a problem. |
Thanks @WardF, if it is of any help, these are the installation steps I followed: 1. Open the
2. Open the the
which produces the following output:
3. Install
which fails with the following output:
|
Here are my steps:
Output of
Error running
|
Some more details on why this happens on Windows and not on Linux:
... I assume that those functions are supposed to be available at link-time for external libraries at all times. And hence it is clearly a bug in netcdf-c and not netcdf-fortran, but do correct me if I'm wrong. |
I believe you are correct. I will try to have this fixed shortly it should be pretty easy :) |
I was not aware that anyone was using the enable-dll configure option, or that it worked at all! Sadly I recently removed this option. I guess I better put it back! So that is a pleasant surprise. I will add mingw to my CI system and restore the DLL stuff I removed from the automake files. |
OK, I have restored the DLL sections to configure.ac and to the relevant Makefile.am files. I have also change netcdf_par.h so that, like netcdf.h, the extra microsoft external declarations are present for every function. @letmaik Can you check to see if this solves your problems building fortran on windows? (You must build my branch from source to check, I can't build DLLs at the moment.) Clone: git@github.com:NetCDF-World-Domination-Council/netcdf-c.git Switch to branch ejh_fill_values and try it. |
@edhartnett I just tried it but get the same errors still. I saw you modified include/netcdf_par.h but this file is not included from |
OK, thanks for checking. I have undone the attempted fix. I will have to slowly back away from this now... |
@edhartnett No worries, I have been working on the fix and will get it in when I'm back in the office; this is similar to issues we've seen in the past with some other exports on Windows. Thanks! |
@WardF How are you progressing on this one? If you need someone for testing just let me know! |
It's been a while, any updates on this? |
I've pushed a branch, gh554.wif, can you try that branch and see if the issue persists? |
Please see my earlier comment #554 (comment). You essentially tried the same here. It would be good if you get a local setup to test it yourself, otherwise it takes too long to iterate on it I think. |
I'm refreshing my memory of this issue, let me see if I can duplicate it on my side now. |
Thinking out loud: Ok, so it looks like some parallel functions are being defined compiled in (dparallel.c) regardless of whether USE_PARALLEL4 is defined. This seems to make sense, as there are no downstream checks in netcdf-fortran, it is just assumed that these functions are present. HOWEVER the functions aren't being exported unless USE_PARALLEL4 (or some such) is defined, hence the issue we are seeing reported here. Fenceposting the functions behind USE_PARALLEL4 will require some downstream changes as well; for now a fix should incorporate the existing logic, these functions will be available and exposed whether parallel I/O is actually there or not. Therefor, we just need to make sure that when netcdf_par.h isn't being included in ncdispatch.h, we include netcdf_f.h instead. Pursuing this line of reasoning, twe make it further but we now get a whole lot of other undefined references. Also, it appears that current netcdf-c So, we have a fix for the immediate issue reported; the rest will have to be sorted out before we can offer official Windows support for netCDF-Fortran. |
Would it be simpler to always export those functions but gut them when |
Always exporting is the decision that was made previously, although I don't have any information regarding this decision. But we're past that issue and now seeing a new one that I'll document here. In current |
This is still an issue with MSYS2, same symptoms. |
Environment Information
configure
)Summary of Issue
The pre-built netcdf-c libraries at http://www.unidata.ucar.edu/software/netcdf/docs/winbin.html are missing certain DLL symbols like nc_create_par_fortran, nc_open_par_fortran, nc_var_par_access. This can be verified with the following command:
dumpbin /exports libnetcdf.dll
.I also built netcdf-c 4.5.0 in an MSYS/mingw64 environment using cmake and faced the same problem.
Not having those functions exported means that it is impossible to link netcdf-fortran against it as it requires those.
I couldn't exactly figure out yet what the reason is but I noticed that there are two files which contain overlapping function declarations with different export keywords: include/netcdf_par.h (not included without parallel option) and include/netcdf_f.h (always included). Maybe that gives a clue?
The text was updated successfully, but these errors were encountered: