c++ - 使用 BOOST property_tree/iostreams/filesystem/foreach - 结果出现链接错误

标签 c++ visual-studio boost wstring boost-iostreams

我尝试构建一个项目,利用 boost/property_tree 和 Boost xml_parser,基于 std::wstring 完整路径。但是我收到链接错误(见下文)。

#include <filesystem> // C++17
#include <codecvt> // C++11
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/foreach.hpp>

#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/filesystem.hpp>
#include <iostream>

void CMainFrame::OnGroup(UINT nID)
{
    // Prepare wstring group-name:
    std::string group_name = m_id_to_string[nID]; //AG: PATCH
    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
    std::wstring group_name_w = converter.from_bytes(group_name);

    using boost::property_tree::ptree;

    // Populate tree structure pt:
    ptree pt;
    boost::filesystem::wpath full_path = CEngine::Instance().GetGroupDirectory() + group_name_w;
    boost::iostreams::file_descriptor_source fs(full_path);
    boost::iostreams::stream<boost::iostreams::file_descriptor_source> fsstream(fs);
    read_xml(fsstream, pt);

    BOOST_FOREACH(ptree::value_type const& v, pt.get_child("Group"))
    {
        unsigned int DeviceId, GridId, MonitorId;

        if (v.first == "Item")
        {
            DeviceId = v.second.get<unsigned int>("DeviceId");
            GridId = v.second.get<unsigned int>("GridId");
            MonitorId = v.second.get<unsigned int>("MonitorId");
        }
    };
}

我收到这个错误:

1>------ Build started: Project: BFC, Configuration: Debug x64 ------
1>MainFrm.cpp
1>LINK : fatal error LNK1104: cannot open file 'libboost_iostreams-vc141-mt-gd-x64-1_67.lib'
1>Done building project "BFC.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

有什么想法吗?

最佳答案

一些 boost 库不仅仅是头文件,因此需要构建这些库。参见 https://www.boost.org/doc/libs/1_67_0/libs/iostreams/doc/installation.html

关于c++ - 使用 BOOST property_tree/iostreams/filesystem/foreach - 结果出现链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50782205/

相关文章:

c++ - boost是如何实现信号和槽的?

c++ - `*' 不能出现在常量表达式中

c++ - 多个if方法的构造约定

C++ 多线程优化

visual-studio - 是否有一种简单的方法可以在 Visual Studio 中包含对程序集的缺失引用?

c++ - boost::asio,线程池和线程监控

c# - 计算百分位数以去除异常值的快速算法

visual-studio - 如何使用颜色选择器对话框在属性编辑器中设置颜色属性?

vb.net - 是否可以在设计时在富文本框中设置文本样式?

python - 公开 C++ 函数,使用 Boost.Python 返回指针