PDA

View Full Version : Linking With Qt VS Add in



rcjohns
13th March 2010, 15:20
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:



int
main (int argc, char* argv[])
{

try
{
std::auto_ptr<material_t> mt (material ("palletmix.xml"));
std::cout << "palletmix.xml loaded !" << std::endl;
}
catch (const xml_schema::exception& e)
{
std::cerr << e << std::endl;
return 1;
}
}


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



#include <QtCore/QCoreApplication>
#include <memory> // std::auto_ptr
#include <iostream>
#include "material_template.hxx"

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

return a.exec();

try
{
std::auto_ptr<material_t> mt (material ("palletmix.xml"));


std::cout << "palletmix.xml loaded !" << std::endl;
}
catch (const xml_schema::exception& e)
{
std::cerr << e << std::endl;
return 1;
}

}


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?

squidge
13th March 2010, 15:32
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)

rcj
14th March 2010, 12:42
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.