【问题标题】:boost::read_graphml visual studio 2013boost::read_graphml 视觉工作室 2013
【发布时间】:2015-12-18 21:52:04
【问题描述】:

boost 库工作正常,除了这个函数 boost::read_graphml() 它说有问题

#include <iostream>
#include <iostream>
#include <string>
#include <fstream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphml.hpp>
int main()
{
using namespace boost;
typedef adjacency_list<vecS, vecS, undirectedS, no_property > Graph;
typedef dynamic_properties Dproperty;
Graph g;
Dproperty dp;

std::string file = "test.graphml";
std::ifstream t(file.c_str());
if (!t.is_open())
{
    std::cout << "loading file failed." << std::endl;
    throw "Could not load file.";
}

read_graphml(t, g, dp);

return 0;
}

错误是:

error LNK2019: unresolved external symbol "void __cdecl boost::read_graphml(class std::basic_istream<char,struct std::char_traits<char> > &,class boost::mutate_graph &,unsigned int)" (?read_graphml@boost@@YAXAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAVmutate_graph@1@I@Z) referenced in function "void __cdecl boost::read_graphml<class boost::adjacency_list<struct boost::vecS,struct boost::vecS,struct boost::directedS,struct boost::property<enum boost::vertex_name_t,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::no_property>,struct boost::no_property,struct boost::no_property,struct boost::listS> >(class std::basic_istream<char,struct std::char_traits<char> > &,class boost::adjacency_list<struct boost::vecS,struct boost::vecS,struct boost::directedS,struct boost::property<enum boost::vertex_name_t,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::no_property>,struct boost::no_property,struct boost::no_property,struct boost::listS> &,struct boost::dynamic_properties &,unsigned int)" (??$read_graphml@V?$adjacency_list@UvecS@boost@@U12@UdirectedS@2@U?$property@W4vertex_name_t@boost@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Uno_property@2@@2@Uno_property@2@U52@UlistS@2@@boost@@@boost@@YAXAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV?$adjacency_list@UvecS@boost@@U12@UdirectedS@2@U?$property@W4vertex_name_t@boost@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Uno_property@2@@2@Uno_property@2@U52@UlistS@2@@0@AAUdynamic_properties@0@I@Z)
1>D:\_example.exe : fatal error LNK1120: 1 unresolved externals

【问题讨论】:

    标签: c++ c++11 boost


    【解决方案1】:

    你需要

    • 链接到已编译的 Boost Graph 库或
    • 在构建中包含BOOST_DIR/libs/graph/src/graphml.cpp

    另请参阅:What is an undefined reference/unresolved external symbol error and how do I fix it?

    【讨论】:

    • 我想链接到图形库也应该有效。PS:是的,根据docs:“要使用 GraphML 阅读器,您需要构建并链接到“boost_graph”库。”
    • @cv_and_he 我不知道它存在。但是,是的,那会起作用:) 可以说它更好。但是 IMO Boost Graph 编译的组件是如此孤立和微小,我通常想静态链接它们
    • 你知道如何构建和链接“boost_graph”库
    • 是的,你也是:boost.org/doc/libs/1_59_0/more/getting_started/windows.html。真的。在这种情况下,只需放入 cpp 文件即可。 (如果你这样做,请确保它与 boost 版本保持同步)
    • 做了但还是同样的问题,没有变化
    猜你喜欢
    • 2014-04-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 1970-01-01
    • 2014-02-04
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多