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
答案 0 :(得分:1)
你需要
BOOST_DIR/libs/graph/src/graphml.cpp
包含在构建中。另请参阅:What is an undefined reference/unresolved external symbol error and how do I fix it?