[英]Linker Command Failed - C++ on OSX
我在 Mac 上為 C++ 使用 HDF5。 我正在使用g++ -std=c++11 test.cpp
編譯我的代碼。 Clang 報告以下錯誤: clang: error: linker command failed with exit code 1 (use -v to see invocation)
,上面的附加信息是ld: symbol(s) not found for architecture x86_64
。
其中一個符號錯誤如下:
"readH5(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from: setupData(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int) in test-9aa0e6.o
我認為與 h5 庫存在 32 位/64 位爭議是否正確?
我是一名計算機科學家,但無論如何我都不是 C++ 專家,因此如果可以為 C++ 初學者編寫答案,我將不勝感激。
此錯誤是由構建時不正確的鏈接引起的。
需要指定鏈接庫。
對於庫,我們必須告訴編譯器 header 文件在哪里,然后用 -l 告訴 linker 庫所在的位置。
你能試試 clang++ 一次嗎?
您還應該嘗試:
g++ test.cpp -o test -lhdf5 -I /usr/local/include
g++ test.cpp -o test -lhdf5 -I <hdf5 lib location>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.