关于Boost库的问题

颖哥儿 2013-04-25 09:16:43
下午花了俩小时,编译完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

这让我如何是好~~
...全文
429 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
一叶之舟 2013-04-26
  • 打赏
  • 举报
回复
在工属性中把boost目录加进去。
赵4老师 2013-04-26
  • 打赏
  • 举报
回复
项目、属性、C/C++、附加包含目录:填写附加头文件所在目录 分号间隔多项 项目、属性、链接器、附加库目录:填写附加依赖库所在目录 分号间隔多项 项目、属性、链接器(点前面的+展开)、输入、附加依赖项:填写附加依赖库的名字.lib 空格间隔多项
ri_aje 2013-04-26
  • 打赏
  • 举报
回复
http://www.boost.org/doc/libs/1_53_0/libs/timer/doc/cpu_timers.html timer 好像只是个 namespace,Win32 release 下换成 boost::timer::cpu_timer 再试一下,其他的都是 include 有问题。
gavinli1991 2013-04-26
  • 打赏
  • 举报
回复
using namespace boost;
颖哥儿 2013-04-26
  • 打赏
  • 举报
回复
谢谢大家的回复,问题已经解决,主要是命名空间的问题。
sduxiaoxiang 2013-04-26
  • 打赏
  • 举报
回复
把boost的头文件路径加到vs配置去吧
ForestDB 2013-04-25
  • 打赏
  • 举报
回复
include path没设置好。
zhcosin 2013-04-25
  • 打赏
  • 举报
回复
明显是头文件路径没设置对。
疯狂的红豆 2013-04-25
  • 打赏
  • 举报
回复
前几天我刚编译好的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
图灵狗 2013-04-25
  • 打赏
  • 举报
回复
从错误信息来看,暂时还没有到32bit和64bit库的问题,应该是搜索路径没有配置好。

64,682

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧