iT邦幫忙

0

用code寫Boost程式問題...

我用code測試Boost程式,出現錯誤,想請前輩先進指導,謝謝.

  • 程式:
#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) << " ");
}
  • 錯誤訊息:
[Running] cd "d:\Desktop\c++\" && g++ boostexample.cpp -o demo && "d:\Desktop\c++\"demo
boostexample.cpp:1:35: fatal error: boost/lambda/lambda.hpp: No such file or directory
 #include <boost/lambda/lambda.hpp>
                                   ^
compilation terminated.
  • c_cpp_properties.json:
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:\\Program Files\\boost\\boost_1_68_0"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "C:\\Program Files\\boost\\boost_1_68_0"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 4
}
  • launch.json:
{
    // 使用 IntelliSense 以得知可用的屬性。
    // 暫留以檢視現有屬性的描述。
    // 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "enter program name, for example ${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}
  • setting.json:
{
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.errorSquiggles": "Enabled",
    "C_Cpp.intelliSenseEngineFallback": "Enabled"
}
  • tasks.json:
{
// 如需 tasks.json 格式的文件, 
    // 請參與 https://go.microsoft.com/fwlink/?LinkId=733558
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
看更多先前的討論...收起先前的討論...
asqweff11 iT邦新手 5 級 ‧ 2019-04-26 09:39:01 檢舉
字面上看起來是沒有lambda.hpp或路徑錯吧
DanSnow iT邦新手 4 級 ‧ 2019-04-26 11:20:51 檢舉
tasks.json 再補個兩個參數吧 "-I", "C:\\Program Files\\boost\\boost_1_68_0"
前輩您好: 請問這兩個參數要加在那裏? 謝謝.
如DanSnow所說,在tasks.json加上"-IC:/Program Files/boost/boost_1_68_0",問題就獲得解決.謝謝前輩指導.

尚未有邦友回答

立即登入回答