我想我已经正确安装了 boost,所以我尝试使用在这里找到的测试“first.cpp” :
#include<iostream>
#include<boost/any.hpp>
int main()
{
boost::any a(5);
a = 7.67;
std::cout<<boost::any_cast<double>(a)<<std::endl;
}
我得到以下信息:
Jason@ITHAKA-DB44CFE1 /home/jason
$ g++ -o first first.cpp
first.cpp:2:24: boost/any.hpp: No such file or directory
first.cpp: In function `int main()':
first.cpp:6: error: `boost' has not been declared
first.cpp:6: error: `any' undeclared (first use this function)
first.cpp:6: error: (Each undeclared identifier is reported only once for each
unction it appears in.)
first.cpp:6: error: expected `;' before "a"
first.cpp:7: error: `a' undeclared (first use this function)
first.cpp:8: error: `boost' has not been declared
first.cpp:8: error: `any_cast' undeclared (first use this function)
first.cpp:8: error: expected primary-expression before "double"
first.cpp:8: error: expected `;' before "double"
first.cpp:9:2: warning: no newline at end of file
Jason@ITHAKA-DB44CFE1 /home/jason
$
我的 boost 库在我的 ./home/Jason/ 中
显然有什么事情发生了。此外,所有的 boost 库本身都使用这个“boost/...”,所以出于某种原因:
1 - 我在 Boost 上做错了 2 - C++/gcc 没有“看到”我的提升
任何输入?