You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Daniel Burrell <da...@gmail.com> on 2008/07/16 00:03:49 UTC

errir LNK2019: unresolved external symbol

Hello,

I am currently using VC8 to compile xerces, I have added a project called
Tasks to the solution with a single file containing main() called
analysefile.cpp.
It is my intention to mess around with xerces in this file.

I'm following the programming guide, and have got stuck at the first stage.
Please take a look at the following screenshot which outlines my setup:

http://www.solong.co.uk/bugs/unresolved.jpg

After having copied and pasted code from the first window of
http://xerces.apache.org/xerces-c/program.html
I can't get my Tasks project to compile due to the following errors.
Since

Error    2    error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static void __cdecl
xercesc_2_8::XMLPlatformUtils::Terminate(void)"
(__imp_?Terminate@XMLPlatformUtils@xercesc_2_8@@SAXXZ) referenced in
function __catch$_main$0    analysefile.obj    Tasks
Error    3    error LNK2019: unresolved external symbol
"__declspec(dllimport) public: static void __cdecl
xercesc_2_8::XMLPlatformUtils::Initialize(char const * const,char const *
const,class xercesc_2_8::PanicHandler * const,class
xercesc_2_8::MemoryManager * const,bool)"
(__imp_?Initialize@XMLPlatformUtils@xercesc_2_8@@SAXQBD0QAVPanicHandler@2
@QAVMemoryManager@2@_N@Z) referenced in function _main    analysefile.obj
Tasks
Error    4    error LNK2001: unresolved external symbol
"__declspec(dllimport) public: static char const * const
xercesc_2_8::XMLUni::fgXercescDefaultLocale"
(__imp_?fgXercescDefaultLocale@XMLUni@xercesc_2_8@@2QBDB)
analysefile.obj    Tasks
Error    5    fatal error LNK1120: 3 unresolved externals
D:\workspaces\test\xerces-c-src_2_8_0\Projects\Win32\VC8\xerces-all\Debug\Tasks.exe
Tasks

Surely it should still compile at this stage? I'm at a loss as to how to
resolve this. Any help much appreciated.

It should be noted however that the following code will compile:

#include <xercesc/util/PlatformUtils.hpp>
// Other include files, declarations, and non-Xerces-C++ initializations.
XERCES_CPP_NAMESPACE_USE
int main(int argc, char* argv[])
{
  /*  ALL THIS CODE COMMENTED OUT
    try {
        XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch) {
        // Do your failure processing here
        return 1;
    }

    // Do your actual work with Xerces-C++ here.
    XMLPlatformUtils::Terminate();
    AND STOP HERE
    */
    // Other terminations and cleanup.
    return 0;
}

clearly it's something to do with the mention of XMLPlatformUtils::

Kind Regards

Dan

Re: errir LNK2019: unresolved external symbol

Posted by Daniel Burrell <da...@gmail.com>.
thank you that was the solution.

Regards

Dan

On Wed, Jul 16, 2008 at 1:17 AM, David Bertoni <db...@apache.org> wrote:

> Daniel Burrell wrote:
>
>> Hello,
>>
>> I am currently using VC8 to compile xerces, I have added a project called
>> Tasks to the solution with a single file containing main() called
>> analysefile.cpp.
>> It is my intention to mess around with xerces in this file.
>>
>> I'm following the programming guide, and have got stuck at the first
>> stage.
>> Please take a look at the following screenshot which outlines my setup:
>>
>> http://www.solong.co.uk/bugs/unresolved.jpg
>>
>> After having copied and pasted code from the first window of
>> http://xerces.apache.org/xerces-c/program.html
>> I can't get my Tasks project to compile due to the following errors.
>> Since
>>
>> Error    2    error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: static void __cdecl
>> xercesc_2_8::XMLPlatformUtils::Terminate(void)"
>> (__imp_?Terminate@XMLPlatformUtils@xercesc_2_8@@SAXXZ) referenced in
>> function __catch$_main$0    analysefile.obj    Tasks
>> Error    3    error LNK2019: unresolved external symbol
>> "__declspec(dllimport) public: static void __cdecl
>> xercesc_2_8::XMLPlatformUtils::Initialize(char const * const,char const *
>> const,class xercesc_2_8::PanicHandler * const,class
>> xercesc_2_8::MemoryManager * const,bool)"
>> (__imp_?Initialize@XMLPlatformUtils@xercesc_2_8@@SAXQBD0QAVPanicHandler@2
>> @QAVMemoryManager@2@_N@Z) referenced in function _main    analysefile.obj
>> Tasks
>> Error    4    error LNK2001: unresolved external symbol
>> "__declspec(dllimport) public: static char const * const
>> xercesc_2_8::XMLUni::fgXercescDefaultLocale"
>> (__imp_?fgXercescDefaultLocale@XMLUni@xercesc_2_8@@2QBDB)
>> analysefile.obj    Tasks
>> Error    5    fatal error LNK1120: 3 unresolved externals
>>
>> D:\workspaces\test\xerces-c-src_2_8_0\Projects\Win32\VC8\xerces-all\Debug\Tasks.exe
>> Tasks
>>
> Have you specified the Xerces-C import library as input to the linker?
>
>>
>> Surely it should still compile at this stage? I'm at a loss as to how to
>> resolve this. Any help much appreciated.
>>
> It's compiling, but it's not linking.
>
>
>> It should be noted however that the following code will compile:
>>
>> #include <xercesc/util/PlatformUtils.hpp>
>> // Other include files, declarations, and non-Xerces-C++ initializations.
>> XERCES_CPP_NAMESPACE_USE
>> int main(int argc, char* argv[])
>> {
>>  /*  ALL THIS CODE COMMENTED OUT
>>    try {
>>        XMLPlatformUtils::Initialize();
>>    }
>>    catch (const XMLException& toCatch) {
>>        // Do your failure processing here
>>        return 1;
>>    }
>>
>>    // Do your actual work with Xerces-C++ here.
>>    XMLPlatformUtils::Terminate();
>>    AND STOP HERE
>>    */
>>    // Other terminations and cleanup.
>>    return 0;
>> }
>>
> This program doesn't call any Xerces-C APIs, which is why you don't get any
> unresolved symbol errors.
>
>
>> clearly it's something to do with the mention of XMLPlatformUtils::
>>
> Yes, you need to link with the Xerces-C import library.  Take a look at one
> of the sample applications to see what extra settings you need for your
> project.
>
> Dave
>

Re: errir LNK2019: unresolved external symbol

Posted by David Bertoni <db...@apache.org>.
Daniel Burrell wrote:
> Hello,
> 
> I am currently using VC8 to compile xerces, I have added a project called
> Tasks to the solution with a single file containing main() called
> analysefile.cpp.
> It is my intention to mess around with xerces in this file.
> 
> I'm following the programming guide, and have got stuck at the first stage.
> Please take a look at the following screenshot which outlines my setup:
> 
> http://www.solong.co.uk/bugs/unresolved.jpg
> 
> After having copied and pasted code from the first window of
> http://xerces.apache.org/xerces-c/program.html
> I can't get my Tasks project to compile due to the following errors.
> Since
> 
> Error    2    error LNK2019: unresolved external symbol
> "__declspec(dllimport) public: static void __cdecl
> xercesc_2_8::XMLPlatformUtils::Terminate(void)"
> (__imp_?Terminate@XMLPlatformUtils@xercesc_2_8@@SAXXZ) referenced in
> function __catch$_main$0    analysefile.obj    Tasks
> Error    3    error LNK2019: unresolved external symbol
> "__declspec(dllimport) public: static void __cdecl
> xercesc_2_8::XMLPlatformUtils::Initialize(char const * const,char const *
> const,class xercesc_2_8::PanicHandler * const,class
> xercesc_2_8::MemoryManager * const,bool)"
> (__imp_?Initialize@XMLPlatformUtils@xercesc_2_8@@SAXQBD0QAVPanicHandler@2
> @QAVMemoryManager@2@_N@Z) referenced in function _main    analysefile.obj
> Tasks
> Error    4    error LNK2001: unresolved external symbol
> "__declspec(dllimport) public: static char const * const
> xercesc_2_8::XMLUni::fgXercescDefaultLocale"
> (__imp_?fgXercescDefaultLocale@XMLUni@xercesc_2_8@@2QBDB)
> analysefile.obj    Tasks
> Error    5    fatal error LNK1120: 3 unresolved externals
> D:\workspaces\test\xerces-c-src_2_8_0\Projects\Win32\VC8\xerces-all\Debug\Tasks.exe
> Tasks
Have you specified the Xerces-C import library as input to the linker?
> 
> Surely it should still compile at this stage? I'm at a loss as to how to
> resolve this. Any help much appreciated.
It's compiling, but it's not linking.

> 
> It should be noted however that the following code will compile:
> 
> #include <xercesc/util/PlatformUtils.hpp>
> // Other include files, declarations, and non-Xerces-C++ initializations.
> XERCES_CPP_NAMESPACE_USE
> int main(int argc, char* argv[])
> {
>   /*  ALL THIS CODE COMMENTED OUT
>     try {
>         XMLPlatformUtils::Initialize();
>     }
>     catch (const XMLException& toCatch) {
>         // Do your failure processing here
>         return 1;
>     }
> 
>     // Do your actual work with Xerces-C++ here.
>     XMLPlatformUtils::Terminate();
>     AND STOP HERE
>     */
>     // Other terminations and cleanup.
>     return 0;
> }
This program doesn't call any Xerces-C APIs, which is why you don't get 
any unresolved symbol errors.

> 
> clearly it's something to do with the mention of XMLPlatformUtils::
Yes, you need to link with the Xerces-C import library.  Take a look at 
one of the sample applications to see what extra settings you need for 
your project.

Dave