我正在嘗試使用hdf5格式來存儲數據。問題是,我無法與圖書館聯繫。我有以下代碼未找到符號 - 鏈接到hdf庫
#include <H5Cpp.h>
int main(void){
H5::H5File file("test_MatrixRoundTrip_Double.h5", H5F_ACC_TRUNC);
}
,並使用
gcc -std=c++11 -o main main.cpp -I /usr/local/include/ -L /usr/local/lib/ -lhdf5 -lhdf5_hl
這總是返回錯誤
Undefined symbols for architecture x86_64:
"H5::FileAccPropList::DEFAULT", referenced from:
_main in main-c207d1.o
"H5::FileCreatPropList::DEFAULT", referenced from:
_main in main-c207d1.o
"H5::H5File::H5File(char const*, unsigned int, H5::FileCreatPropList const&, H5::FileAccPropList const&)", referenced from:
_main in main-c207d1.o
"H5::H5File::~H5File()", referenced from:
_main in main-c207d1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我安裝使用
brew install homebrew/science/hdf5
在OSX的HDF5庫編譯我在做什麼這裏錯了嗎?
你爲什麼用gcc編譯?你有嘗試過使用g ++嗎? – sestus
g ++產生相同的錯誤。我用下面的命令'g ++ -std = C++ 11 -o main main.cpp -I/usr/local/include/-L/usr/local/lib/-lhdf5 -lhdf5_hl' – physicsGuy