【问题标题】:Cannot compile using any external libraries (Codeblocks)无法使用任何外部库(代码块)进行编译
【发布时间】:2017-05-16 08:15:09
【问题描述】:

我无法使用 Code::Blocks 上的外部库编译任何代码。

我尝试使用 boost lambda 示例:

#include <boost/lambda/lambda.hpp>

#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
}

我为库设置了一个全局环境变量: https://imgur.com/a/maiRC ...而且我认为我正确设置了构建选项。 https://imgur.com/a/BP0Xk

但是我的构建检测不到头文件:

||=== Build: Debug in boost test (compiler: GNU GCC Compiler) ===|
C:\Documents and Settings\Charlotte\My Documents\wxTest\boost test\boo.cpp|1|fatal error: boost/lambda/lambda.hpp: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

【问题讨论】:

  • 'base' 和 'include'/'lib' 目录中的大小写不匹配是故意的吗?
  • 感谢您的帮助。不,但我刚刚解决了这个问题,但它没有用。
  • 这还是同样的错误吗?尝试使用“include”而不是 并将其放在所有 std 包含之后。

标签: c++ windows compiler-errors codeblocks


【解决方案1】:

不幸的是,您的第一张图片中的增强包含路径被切断了。不过好像

C:\Boost\include\boost-1_62\boost

对吗?

这很可能是不正确的。如果您像以前一样包含 lambda 标头(这也是包含 boost 标头的常用方法)

#include <boost/lambda/lambda.hpp>

那么需要存在一个名为

的文件
C:\Boost\include\boost-1_62\boost\boost\lambda\lambda.hpp

这不符合正常的 Boost 目录布局。里面有一个boost 太多了。尝试将您的全局环境 Boost 路径设置为:

C:\Boost\include\boost-1_62

【讨论】:

  • @VVV 在 Stackoverflow 上说 Thanks 的方式是 accept the answer 不接受可以解决您问题的答案会阻止读者回答您未来的问题。
猜你喜欢
  • 1970-01-01
  • 2015-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-08
  • 1970-01-01
  • 1970-01-01
  • 2014-07-10
相关资源
最近更新 更多