我是 blitz 库的初学者。当我尝试在 Blitz++ 用户指南中编译输入和输出数组的代码时,如下所示:
#include <blitz/array.h>
#include <fstream>
BZ_USING_NAMESPACE(blitz)
const char* filename = "io.data";
void write_arrays()
{
ofstream ofs(filename);
if (ofs.bad())
{
cerr << "Unable to write to file: " << filename << endl;
exit(1);
}
Array<float,3> A(3,4,5);
A = 111 + tensor::i + 10 * tensor::j + 100 * tensor::k;
ofs << A << endl;
Array<float,2> B(3,4);
B = 11 + tensor::i + 10 * tensor::j;
ofs << B << endl;
Array<float,1> C(4);
C = 1 + tensor::i;
ofs << C << endl;
}
int main()
{
write_arrays();
ifstream ifs(filename);
if (ifs.bad())
{
cerr << "Unable to open file: " << filename << endl;
exit(1);
}
Array<float,3> A;
Array<float,2> B;
Array<float,1> C;
ifs >> A >> B >> C;
cout << "Arrays restored from file: " << A << B << C << endl;
return 0;
}
我总是遇到以下错误:
"
readtest.cpp:(.text+0x246): undefined reference to `blitz::tensor::k'
readtest.cpp:(.text+0x26c): undefined reference to `blitz::tensor::j'
readtest.cpp:(.text+0x281): undefined reference to `blitz::tensor::i'
readtest.cpp:(.text+0x69a): undefined reference to `blitz::tensor::j'
readtest.cpp:(.text+0x6b8): undefined reference to `blitz::tensor::i'
readtest.cpp:(.text+0x981): undefined reference to `blitz::tensor::i'
"
有人可以帮我吗?非常感谢!