Loking for an hdf5 version compatible with go1.9.2

Hello everyone,

I’m looking for an HDF5 version compatible with the golang version 1.9.2 to build a specific project, that requires this version. I already installed the HDF5 library version 1.10.1 on ubuntu18.04 using “sudo apt install libhdf5-dev” , but when I build the project it gave me the following error:

gonum.org/v1/hdf5 …/…/…/gonum.org/v1/hdf5/h5a_attribute.go:96: cannot use C.ulong(uint(unsafe.Sizeof(byte(0))) * (dlen + 1)) (type C.ulong) as type C.size_t in argument to _Cfunc__CMalloc …/…/…/gonum.org/v1/hdf5/h5p_proplist.go:80: cannot use _Cfunc_H5Pget_chunk(C.hid_t(p.Identifier.id), C.int(ndims), &c_dims[0]) (type C.int) as type C.herr_t in argument to h5err

Could anyone helps me solve this problem?
Is it possible to build the project using another version of hdf5 lib?

Thank you so much,
Best regards.

This looks like a Go wrapper issue. This commit fixed the first error. I believe the other issue (herr_t) was fixed here.

Please do not use HDF5 1.10.1. Get HDF5 1.10.8 and get the latest version of the Go wrapper.

G.

1 Like

Thank you for your reply,
I’m totally new to the hdf5-lib and Golang, so I don’t know if I did the right modification or not:
from h5a_attribute.go file I removed this line:

cstr := (*C.char)(unsafe.Pointer(C.malloc(C.ulong(uint(unsafe.Sizeof(byte(0))) * (dlen + 1)))))
and replaced it by:
cstr := (*C.char)(unsafe.Pointer(C.malloc(C.size_t(uint(unsafe.Sizeof(byte(0))) * (dlen + 1)))))

it fixed the first issue, but the second did not because when I tried to modify the files mentioned in the link (some of them I didn’t find such as h5g.go h5t.go…) I found them already updated.

How about replacing line 80 of h5p_proplist.go

if err = h5err(C.H5Pget_chunk(C.hid_t(p.id), C.int(ndims), &c_dims[0])); err != nil {

with

if err = h5err(C.herr_t(C.H5Pget_chunk(C.hid_t(p.id), C.int(ndims), &c_dims[0]))); err != nil {

?

1 Like

Thank you so much, it fixed the error. I really appreciate your help.

1 Like

You are welcome. Please consider contributing those changes back to the original project. G.

2 Likes