c - Getting ‘undefined reference to’ when compiling simple HDF5 example in Eclipse -
i started c , hdf5 question might easy answer.
i tried example-code http://beige.ucs.indiana.edu/i590/node122.html create hdf5 file.
#include "hdf5.h" #define file "file.h5" main() { hid_t file_id; /* file identifier */ herr_t status; /* create new file using default properties. */ file_id = h5fcreate(file, h5f_acc_trunc, h5p_default, h5p_default); /* terminate access file. */ status = h5fclose(file_id); } i tried compile eclipse , got 5 error messages:
make: *** [read_hdf5] error 1 skipping incompatible /usr/lib/libc.so when searching -lc undefined reference `h5check_version' undefined reference `h5fcreate' undefined reference `h5fclose' what went wrong?
thanks help!!!
you need link hdf5 library when compiling. errors mean code these functions missing, because didn't link library file contains them. easiest way compile using h5cc described in tutorial mentioned. otherwise, if prefer compiling in eclipse, need search linker flags setting , add correct flags can find typing h5cc -show in terminal.
for instance, me, h5cc -show gives
clang -i/usr/local/include -l/usr/local/cellar/hdf5/1.8.12/lib /usr/local/cellar/hdf5/1.8.12/lib/libhdf5_hl.a /usr/local/cellar/hdf5/1.8.12/lib/libhdf5.a -l/usr/local/lib -lsz -lz -ldl -lm piece piece:
clangcompiler-i/usr/local/includeflag telling compiler search header files inside/usr/local/includedirectory-l/usr/local/cellar/hdf5/1.8.12/lib,-l/usr/local/libflags telling linker search libraries inside these directories/usr/local/cellar/hdf5/1.8.12/lib/libhdf5_hl.a,/usr/local/cellar/hdf5/1.8.12/lib/libhdf5.afull path 2 hdf5 static libraries (telling linker link them)-lsz,-lz,-ldl,-lmflags telling linker link librariessz,z,dl,m
this overkill. if hdf5 installed in standard location, might enough add -lhdf5 linker flags.
Comments
Post a Comment