Reputation: 13319
I've started learning HDF5 and can't get passed the following issue with HDF5 C++.
(Background info: I've installed hdf5 via Homebrew on OSX El Capitan. I've succeeded with a few programs using the generic C API and the Python module h5py, but the C++ API isn't working.)
Here's an example of my command:
h5c++ simple.cpp
I try to compile but receive the following error:
Undefined symbols for architecture x86_64:
"H5::H5File::H5File(...)" ...
"H5::CommonFG::createDataSet(...)" ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Other information:
I include H5Cpp.h. I am under the impression it is the only file I need to include.
At first, I thought C++ might not be enabled by default, despite what I read in the the Homebrew formula. As a double-check, I uninstalled and re-installed with --with-cxx
(obviously, that didn't work).
What are these errors really telling me? Why doesn't my C++ HDF5 program work? Are there any tricks I should know about?
Upvotes: 3
Views: 1077
Reputation: 13319
I discovered the problem when collaborating with some friends and using the verbose output from h5c++:
h5c++ -v simple.cpp
I had installed the anaconda platform, which comes with HDF5. I'm not sure if the error is a result of a conflict between anaconda HDF5 and Homebrew HDF5, but using the Homebrew HDF5 executable fixes the problem.
What I actually did was uninstall anaconda.
(Alternatively, I could just fix my PATH bash variable to not include anaconda tools. In ~/.bash_profile
, the anaconda platform installation added a line that updates PATH to include its tools. Commenting out the line and restarting bash, or modifying PATH by hand stopped the conflict between versions of HDF5.)
Upvotes: 2