Results 1 to 3 of 3

Thread: Linking With Qt VS Add in

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Linking With Qt VS Add in

    Hi -
    I am trying to update some code I have to QT- 4.6.2 with VS2008 and it no longer seems to want to link in the xerces-c library.

    so I have created 2 tiny programs (they really are pretty non-functional) to debug the issue; the first makes no use of Qt and works fine:

    Qt Code:
    1. int
    2. main (int argc, char* argv[])
    3. {
    4.  
    5. try
    6. {
    7. std::auto_ptr<material_t> mt (material ("palletmix.xml"));
    8. std::cout << "palletmix.xml loaded !" << std::endl;
    9. }
    10. catch (const xml_schema::exception& e)
    11. {
    12. std::cerr << e << std::endl;
    13. return 1;
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    This uses xerces-c_3D.lib in the linker input section...

    when I try to turn this into the most trivial Qt program: ( I really should use Qt Streams etc , but this is the most trivial change I could see

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <memory> // std::auto_ptr
    3. #include <iostream>
    4. #include "material_template.hxx"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QCoreApplication a(argc, argv);
    9.  
    10. return a.exec();
    11.  
    12. try
    13. {
    14. std::auto_ptr<material_t> mt (material ("palletmix.xml"));
    15.  
    16.  
    17. std::cout << "palletmix.xml loaded !" << std::endl;
    18. }
    19. catch (const xml_schema::exception& e)
    20. {
    21. std::cerr << e << std::endl;
    22. return 1;
    23. }
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 

    I get linker errors:

    1>------ Build started: Project: MostQtXml, Configuration: Debug Win32 ------
    1>Compiling...
    1>material_template.cxx
    1>main.cpp
    1>Generating Code...
    1>Linking...
    1>material_template.obj : error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_0::InputSource::getEncoding(void)const " (?getEncoding@InputSource@xercesc_3_0@@UBEPBGXZ)
    1>material_template.obj : error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_0::InputSource::getPublicId(void)const " (?getPublicId@InputSource@xercesc_3_0@@UBEPBGXZ)
    1>material_template.obj : error LNK2001: unresolved external symbol "public: virtual unsigned short const * __thiscall xercesc_3_0::InputSource::getSystemId(void)const " (?getSystemId@InputSource@xercesc_3_0@@UBEPBGXZ)
    1>material_template.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall xercesc_3_0::InputSource::setEncoding(unsigned short const * const)" (?setEncoding@InputSource@xercesc_3_0@@UAEXQBG@Z)
    ...
    ...

    if I change the name of the xerces library I get a can't open file error, so it is seeing the library:

    1>------ Build started: Project: MostQtXml, Configuration: Debug Win32 ------
    1>Linking...
    1>LINK : fatal error LNK1181: cannot open input file 'xerces-c_3cD.lib'
    1>Build log was saved at "file://c:\Documents and Settings\116100\My Documents\MCNPX\MostQtXml\MostQtXml\Debug\BuildLog .htm"
    1>MostQtXml - 1 error(s), 0 warning(s)

    How do you add an external library?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Linking With Qt VS Add in

    Does your library actually contain those functions which are declared as missing? If the library wasn't compiled with VS, then the functions may be named differently (eg. you can't use GCC libraries with VS)

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Linking With Qt VS Add in

    Found the critical issue: Standard VC++ sets "treat wchar_t as builtin" to yes. the Qt Vs Add in sets the property to no. Resetting it back to yes enables a complete link. The app seems functional, but there may be some issues in the finer points of compatibility yet to surface.

Similar Threads

  1. Linking to a DLL
    By JohnGaby in forum Newbie
    Replies: 1
    Last Post: 14th October 2009, 19:52
  2. Linking
    By ^NyAw^ in forum General Programming
    Replies: 7
    Last Post: 30th October 2008, 17:37
  3. dll linking
    By Project25 in forum Qt Programming
    Replies: 3
    Last Post: 12th July 2007, 07:39
  4. linking in QWhatsThis
    By Greenmanspirit in forum Qt Programming
    Replies: 4
    Last Post: 4th June 2007, 20:02
  5. linking
    By mickey in forum Newbie
    Replies: 5
    Last Post: 22nd April 2006, 21:37

Tags for this Thread

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.