Bug 1229872
| Summary: | cannot build against static netcdf library | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Jos de Kloe <josdekloe> |
| Component: | netcdf | Assignee: | Orion Poplawski <orion> |
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 21 | CC: | benoit.ozell, dakingun, jspaleta, orion, pertusus |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-06-24 20:10:41 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
In addition, if I try to link without the -static flag, I get these errors:
>gcc test.c /usr/lib64/libnetcdf.a -lhdf5_hl -lhdf5 -lm -lz -lcurl
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `close_netcdf4_file':
(.text+0x12e): undefined reference to `SDend'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xc4e): undefined reference to `SDstart'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xc6c): undefined reference to `SDfileinfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xd07): undefined reference to `SDattrinfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xd8d): undefined reference to `SDreadattr'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xed0): undefined reference to `SDselect'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xf26): undefined reference to `SDgetinfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0xf6d): undefined reference to `SDgetinfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0x102b): undefined reference to `SDgetfillvalue'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0x10e4): undefined reference to `SDattrinfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0x1170): undefined reference to `SDreadattr'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0x1279): undefined reference to `SDgetdimid'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4file.o): In function `nc4_open_hdf4_file':
(.text+0x1298): undefined reference to `SDdiminfo'
/usr/lib64/libnetcdf.a(libnetcdf4_la-nc4var.o): In function `nc4_get_hdf4_vara.isra.1':
(.text+0x1206): undefined reference to `SDreaddata'
collect2: error: ld returned 1 exit status
Well, you can't get a completely static binary, because not all required libraries are available statically. I think this is the best you can do: gcc test.c -Wl,-Bstatic -lnetcdf -lhdf5_hl -lhdf5 -L/usr/lib64/hdf -lmfhdf -ldf -lm -Wl,-Bdynamic -ldl -lcurl -ljpeg -lz I've been considering dropping the netcdf-static library completely. Why do you want to link statically? Thanks for your answer. I had to google a bit to find that I needed to install hdf-devel as well to get libdf.a and libmfhdf.a, but then your invocation works fine. The reason I asked is that I encountered an old build script that used static linking. I know it is not the Fedora way of things nowadays, but since there was a netcdf-static package available I thought I'd give it a try. Ofcourse the old idea of static building was that it would make it easier to take your executables from one platform to another. There is no reason why I would need a purely static build at all at the moment, so nothing needs to be fixed I think. Since the resulting executable still depends on a fair amount of shared libraries if you build it this way, I think the question of dropping the netcdf-static packaige is a valid one, and I would not mind if it got deleted in a future Fedora release. |
Description of problem: static building using the /usr/lib64/libnetcdf.a library seems not to work Version-Release number of selected component (if applicable): netcdf-static-4.3.2-5.fc21.x86_64 How reproducible: always Steps to Reproduce: 1. take a simple piece of dummy c code like this: >cat test.c #include <netcdf.h> main() { int v; nc_create("dummy.nc", NC_CLOBBER, &v); } 2. try to compile it with the static flag: gcc -static test.c -lnetcdf -lhdf5_hl -lhdf5 -lm Actual results: a load of linking errors occur, indicating problems with at least libcurl and libz: /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libnetcdf.a(liboc_la-occurlfunctions.o): In function `oc_curl_debug': (.text+0xa8): undefined reference to `curl_easy_setopt' /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libnetcdf.a(liboc_la-occurlfunctions.o): In function `oc_curl_protocols': (.text+0x10a): undefined reference to `curl_version_info' /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libnetcdf.a(liboc_la-occurlfunctions.o): In function `ocset_curl_flags': (.text+0x1e5): undefined reference to `curl_easy_setopt' ... /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libhdf5.a(H5Zdeflate.o): In function `H5Z_filter_deflate': (.text+0x3c1): undefined reference to `inflateEnd' /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libhdf5.a(H5Zdeflate.o): In function `H5Z_filter_deflate': (.text+0x510): undefined reference to `compress2' collect2: error: ld returned 1 exit status Expected results: a functioning executable should be produced Additional info: it seems to me libcurl and libz are only provided as shared libraries for Fedora, so maybe this netcdf-static is no longer functional and could be phased out? Or am I overlooking something obvious?