error LNK2019: unresolved external symbol

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eagerlearner
    New Member
    • Jul 2007
    • 29

    error LNK2019: unresolved external symbol

    I tried to figure out myself but still can't figure out,
    Basically there is two file, main.cpp, ParserDom.h. The ParserDom.h was located in the "html" folder which located same place as main.cpp
    But when I compiled, I get error LNK2019: unresolved external symbol
    which all of them referring to member function of ParserDom class. Can anyone figure out ?
    I always get this kind of problem, can anyone give me some tips what is the causes and how can I avoid it in future ?
    Thank you. The code was taken from http://htmlcxx.sourceforge.net/

    using Visual Studion 2005

    main.cpp file
    Code:
    #include <iostream>
    #include <string>
    #include "html/ParserDom.h"
    
    using namespace std;
    using namespace htmlcxx;
    
    
    int main()
    {
    	string html = "<html><body>hey</body></html>";
    	HTML::ParserDom parser;
    	tree<HTML::Node> dom = parser.parseTree(html);
    	return 0;
    }
    ParserDom.h header file
    Code:
    #ifndef __HTML_PARSER_DOM_H__
    #define __HTML_PARSER_DOM_H__
    
    #include "ParserSax.h"
    #include "tree.h"
    
    namespace htmlcxx
    {
    	namespace HTML
    	{
    		class ParserDom : public ParserSax
    		{
    			public:
    				ParserDom() {}
    				~ParserDom() {}
    
    				const tree<Node> &parseTree(const std::string &html);
    				const tree<Node> &getTree()
    				{ return mHtmlTree; }
    
    			protected:
    				virtual void beginParsing();
    
    				virtual void foundTag(Node node, bool isEnd);
    				virtual void foundText(Node node);
    				virtual void foundComment(Node node);
    
    				virtual void endParsing();
    				
    				tree<Node> mHtmlTree;
    				tree<Node>::iterator mCurrentState;
    		};
    
    		std::ostream &operator<<(std::ostream &stream, const tree<HTML::Node> &tr);
    	} //namespace HTML
    } //namespace htmlcxx
    
    #endif
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    I think you simply forgot to link against a library that actually contains the compiled
    definition of that ParserDom class. What do the docs say?

    kind regards,

    Jos

    Comment

    • eagerlearner
      New Member
      • Jul 2007
      • 29

      #3
      Thanks for the reply, really appreciate that. The project can be downloaded here http://sf.net/projects/htmlcxx
      I guess, I have to install first, which I have not done yet, I saw those MakeFile which I encounter very often but have not yet know how to use it. I need to run the config file but what kind of shell i need to run ? can give a very brief instruction ? Thank you.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by eagerlearner
        Thanks for the reply, really appreciate that. The project can be downloaded here http://sf.net/projects/htmlcxx
        I guess, I have to install first, which I have not done yet,
        That explains the unresolved external that your linker encounterd.

        Originally posted by eagerlearner
        I saw those MakeFile which I encounter very often but have not yet know how to
        use it. I need to run the config file but what kind of shell i need to run ? can give
        a very brief instruction ? Thank you.
        This is what I read from that download page:
        Operating System: All POSIX (Linux/BSD/UNIX-like OSes), Linux

        so, at least you should have cygwin or equivalent running if you're using a Windows
        machine. Otherwise, simply run the configuration (just type in "make").
        Most (if not all) proper Unix/Linux projects try to figure out what's available on
        your system and they use that or they bail out if the project can't run on your
        system. That's what the configuration part does. Most of the time it compiles
        and installs the libraries and all the other stuff for you. If you're lucky these
        projects even come with a proper manual ;-)

        kind regards,

        Jos

        Comment

        • eagerlearner
          New Member
          • Jul 2007
          • 29

          #5
          Thanks, I am using windows, so now I am using cywin for my very first time, change my directory to the sources file with "cd [DIRECTORY]" , after that I type "configure" , gives command not found, can give me a little hint on running the configure in cywin, if you don't mind ? Really2 thank you.

          Comment

          • eagerlearner
            New Member
            • Jul 2007
            • 29

            #6
            Thanks, finally I get it to work, when I create header file and copy it from htmlcxx source file manually to include into my project. I don't use the configure or makefile at all, It works so graceful. Thanks.

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by eagerlearner
              Thanks, finally I get it to work, when I create header file and copy it from htmlcxx source file manually to include into my project. I don't use the configure or makefile at all, It works so graceful. Thanks.
              Hm, you're not supposed to scrape the bits and pieces from another project's
              source and header files each time you want to use something. btw, you typed
              'configure'; what happens if/when you just type 'make'? There should be a clean
              way to install that project on your machine. Any manual pages mayhap?

              kind regards,

              Jos

              Comment

              • RRick
                Recognized Expert Contributor
                • Feb 2007
                • 463

                #8
                With Unix installations there are usually several steps to follow.

                First check for an INSTALL or README file at the top source directory. This might have tips for your platform.

                If one exists in the source directory, run the configure script. Sometimes the PATH variable is touchy and you need to run >> ./configure. This checks the system and can set up the makefiles for you.

                If configure is successful, then run >> make.

                After that, run >> make install. This will install the various parts of the program, usually to /usr/local/xxx.

                Comment

                Working...