The last version of C++ IDE I was using is VC98, so a lot of things have changed and I'm confused.
I'm trying to create a class MyParser
. I have its header file MyParser.h
in Header Files
in the solution explorer, and the source file MyParser.cpp
in Source Files
.
MyParser.h
looks like below.
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
using namespace std;
class MyParser
{
private:
boost::property_tree::ptree pt;
public:
MyParser(string str);
};
MyParser.cpp is:
#include "MyParser.h"
#include <iostream>
using namespace std;
MyParser::MyParser(std::string str)
{
boost::property_tree::read_xml(str, this->pt);
}
The main.cpp
(in a separate project under the same solution) is
#include <string>
#include <iostream>
#include "MyParser.h"
using namespace std;
int main()
{
string content = "some xml string.....";
MyParser parser = MyParser(content);
return 0;
}
Then I've got LNK2019
error:
unresolved external symbol "public: __cdecl MyParser::MyParser(class std::basic_string,class std::allocator >)" (??0MyParser@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function main test C:\MySpace\test\test.obj
However, as soon as I move the implementation of the constructor into MyParser.h
, the error disappears.
Could anyone point it out to me what is wrong with my code/config? Many thanks