Results 1 to 2 of 2

Thread: QDomDocument won't build/compile

  1. #1
    Join Date
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDomDocument won't build/compile

    All,

    I'm running QtCreator 2.2.1 on ubuntu 32-bit. Says I'm using 4.7.3 of Qt. So far so good. I needed to so some simple XML. Stole this example from this board which others claims works just fine.


    Qt Code:
    1. #include <QtXml/QDomDocument>
    2. #include <QtXml/QXmlSimpleReader>
    3. #include <QDebug>
    4.  
    5. int main(){
    6. QString xmlString("<original> </original>");
    7. doc.setContent(xmlString);
    8. QDomElement docElem = doc.documentElement();
    9. qDebug() << "Without QXmlSimpleReader \t- element contains" <<docElem.text() << "\tlength="<< docElem.text().length();
    10. doc.clear();
    11. source.setData(xmlString);
    12. doc.setContent(&source, &reader);
    13. docElem = doc.documentElement();
    14. qDebug() << "With QXmlSimpleReader \t- element contains" <<docElem.text() << "\tlength="<< docElem.text().length();
    15. }
    To copy to clipboard, switch view to plain text mode 

    When I try to compile I get this error along with a rash of others.

    (.text.startup+0x38):-1: error: undefined reference to `QDomDocument::QDomDocument()'

    The header files are all there. What is missing from this installation? It's probably something simple, it's late and I'm tired.

    Thanks,
    Roland


    Added after 14 minutes:


    Never mind

    I forgot to add +=xml in the pro file

    stupid things happen when you get tired.
    Last edited by RolandHughes; 30th April 2012 at 01:08.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDomDocument won't build/compile

    You should also learn to distinguish between compile and link errors. What you have posted here looks like a link error to me, and has nothing to do with whether the header files are there or not (which they are). The error you posted is the linker telling you it can't find something it needs in the object and library files you've told it to link in. Adding +xml in pro file is specifying a link library, as you discovered.

    Programming tired is like driving tired. It's better to pull over and get some rest, otherwise you may fall asleep at the wheel and run into something.

Similar Threads

  1. Cannot build/compile C++ code
    By BucketOfFire in forum Newbie
    Replies: 5
    Last Post: 30th December 2011, 14:28
  2. 3583 compile errors when trying to build for Symbian
    By woodtluk in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2010, 21:26
  3. Compile Qt 4.6.2 with VS2008 - exception in release build, debug ok
    By LynneV in forum Installation and Deployment
    Replies: 0
    Last Post: 7th June 2010, 04:52
  4. QDomDocument inside other QDomDocument
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2008, 15:27
  5. build/compile QT4.4 with VisStudio2008
    By mgdqt in forum Installation and Deployment
    Replies: 2
    Last Post: 30th May 2008, 16:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.