0
我有後來使用Xerces-c,它可以構建爲靜態或動態庫提供的代碼。如果不包括在編譯器錯誤路線的結果,但是當我添加#include <xercesc/util/PlatformUtils.hpp>
的Visual Studio 2012給了我一個鏈接錯誤,他說:包含靜態庫的頭給dllimport錯誤
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLPlatformUtils::Initialize(char const * const,char const * const,class xercesc_3_1::PanicHandler * const,class xercesc_3_1::MemoryManager * const)" ([email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl xercesc_3_1::XMLPlatformUtils::Terminate(void)" ([email protected]@[email protected]@SAXXZ) referenced in function __catch$_main$0
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static char const * const xercesc_3_1::XMLUni::fgXercescDefaultLocale" ([email protected]@[email protected]@2QBDB)
基於錯誤的dllimport
部分似乎它沒有找到一個dll 。當我將Xerces-c構建爲動態庫並鏈接到它時,錯誤就消失了。但是,如果我將Xerces-c構建爲靜態庫並鏈接到它,仍然會出現相同的錯誤。所以我的問題是爲什麼當我包含並鏈接到一個靜態庫時,我得到一個錯誤,要求一個DLL?
using namespace xercesc;
int main(int argc, char* argv[])
{
std::ifstream inputFile(argv[1]);
char c = inputFile.get();
while (inputFile.good()) {
std::cout << c;
c = inputFile.get();
}
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
// Do your failure processing here
return 1;
}
// Do your actual work with Xerces-C++ here.
//XercesDOMParser parser;
//parser.useScanner(XMLUni::fgDGXMLScanner);
XMLPlatformUtils::Terminate();
// Other terminations and cleanup.
return 0;
}