链接器命令失败- OSX上的c++



我在mac上使用HDF5的c++。我正在用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++初学者编写答案,我将非常感激。

这个错误是由连接在构建时不当引起的。

需要指定链接库。

对于库,我们必须告诉编译器头文件在哪里,然后用-l告诉链接器库在哪里。

你能试一下clang++吗?

你也可以试试:

g++ test.cpp -o test -lhdf5 -I /usr/local/include

g++ test.cpp -o test -lhdf5 -I <hdf5 lib location>

最新更新