When linking against the static library you have to define the macro
XERCES_STATIC_LIBRARY in the preprocessor tab of the C/C++ compiler
options. Otherwise the function signatures are decorated with the
__declspec(dllimport) directive
Alberto
On 2/16/2010 6:19 AM, markrbray wrote:
Hi,
I'm having trouble getting the my sample application to build and link with
xerces-c 3.0.1. I'm running on Windows Vista and using Visual Studio 2008
express edition. I was able to build the xerces library just fine (i.e. the
"xerces-c-3.0.1\projects\Win32\VC9\xerces-all\XercesLib\XercesLib.vcproj"
project). However, when I try to build the sample application from the
apache xerces c++ "programming guide" I get the following link errors:
1>Linking...
1>vrp_opt.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static void __cdecl
xercesc_3_0::XMLPlatformUtils::Terminate(void)"
(__imp_?termin...@xmlplatformutils@xercesc_3_0@@SAXXZ) referenced in
function __catch$_wmain$0
1>vrp_opt.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static void __cdecl
xercesc_3_0::XMLPlatformUtils::Initialize(char const * const,char const *
const,class xercesc_3_0::PanicHandler * const,class
xercesc_3_0::MemoryManager * const)"
(__imp_?initial...@xmlplatformutils@xercesc_3_0@@saxqbd0qavpanichand...@2@qavmemorymana...@2@@Z)
referenced in function _wmain
1>vrp_opt.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: static char const * const
xercesc_3_0::XMLUni::fgXercescDefaultLocale"
(__imp_?fgxercescdefaultloc...@xmluni@xercesc_3_0@@2QBDB)
1>C:\VRP\vrp_opt\Debug\vrp_opt.exe : fatal error LNK1120: 3 unresolved
externals
1>Build log was saved at "file://c:\VRP\vrp_opt\vrp_opt\Debug\BuildLog.htm"
1>vrp_opt - 4 error(s), 0 warning(s)
Below is the code I'm trying to build:
// vrp_opt.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<windows.h>
#include<xercesc/util/PlatformUtils.hpp>
using namespace xercesc;
int _tmain(int argc, _TCHAR* argv[])
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
XMLPlatformUtils::Terminate();
// Other terminations and cleanup.
return 0;
}
The xerces library was built as a static lib (in visual studio
"Configuration Properties> General> Configuration Type = Static Library
(.lib)") and the runtime library is "Multi-threaded Debug (/MTd)".
My sample application (code shown above) has the following settings in
visual studio:
Configuration Properties> C/C++> Additional Include directories =
..\..\xerces-c-3.0.1\src
Configuration Properties> C/C++> Code Generation> Runtime library =
Multi-threaded Debug (/MTd)
Configuration Properties> C/C++> Advanced> Calling convention = __cdecl
(/Gd)
Configuration Properties> Linker> Additional Library Directories =
..\..\xerces-c-3.0.1\Build\Win32\VC9\Debug\
Configuration Properties> Linker> Input> Additional Dependencies =
XercesLib.lib
It seems like I have the right include directory and path to the static
library, but I still get these errors. What am I missing? Any help would
be much appreciated.
Thank you,
Mark Bray