关于Boost库的问题
下午花了俩小时,编译完boost(1.49)库,折腾了一晚上也没折腾好。
由于是64bit机器,将boost编译成了64bit(不知道是否应该保持默认的32bit),然后将路径(include和lib)都添加好,在include的时候也能顺利找到头文件,但是运行的时候问题来了,比如使用
#include<boost/timer.hpp>
#include<iostream>
int main(void)
{
timer t;
return 0;
}
在x64 debug下提示:fatal error C1083: Cannot open include file: 'boost/timer.hpp': No such file or directory;
在x64 release下提示:fatal error C1083: Cannot open include file: 'boost/timer.hpp': No such file or directory;
然后又尝试了
在Win32 debug 下提示:fatal error C1083: Cannot open include file: 'boost/timer.hpp': No such file or directory;
在Win32 release下提示:
error C2065: 'timer' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 't'
error C2065: 't' : undeclared identifier
这让我如何是好~~ Boost 64位
[解决办法]
从错误信息来看,暂时还没有到32bit和64bit库的问题,应该是搜索路径没有配置好。
[解决办法]
前几天我刚编译好的Boost库,看的就是这个链接,感觉也没啥不顺的啊,注意路径。
#include <boost/assert.hpp>
#include <boost/checked_delete.hpp>
#include <boost/throw_exception.hpp>
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/smart_ptr/detail/sp_convertible.hpp>
Boost源文件的include形式都是上面那种,也就是说你编译器的VC++目录要截止与boost的上一级,拿我的来说:G:\Boost\boost_1_47_0;$(IncludePath)这是我的编译器VC++目录路径,G:\Boost\boost_1_47_0\boost\.. 这是我的Boost库的安装目录,..代表的是一些Boost库中的具体内容了。你把VC++目录设置成G:\Boost\boost_1_47_0;编译器会根据这个目录继续往下找boost/../../等源文件。正好符合boost库内部源文件的include方式#include <boost/detail/workaround.hpp>
下面是我参看的链接
http://www.programlife.net/boost-compile-and-config.html
[解决办法]
using namespace boost;
[解决办法]
http://www.boost.org/doc/libs/1_53_0/libs/timer/doc/cpu_timers.html
timer 好像只是个 namespace,Win32 release 下换成 boost::timer::cpu_timer 再试一下,其他的都是 include 有问题。
[解决办法]
项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项
项目、属性、链接器、附加库目录:填写附加依赖库所在目录 分号间隔多项
项目、属性、链接器(点前面的+展开)、输入、附加依赖项:填写附加依赖库的名字.lib 空格间隔多项