Xerces-c-3.1.4 DLLの使い方を習得しようとしています。ソースをダウンロードし、VS Studio Express 2015のxerces-all.slnを使用してDLLを作成しました。未解決の外部 'xercesc_3_1 :: XMLPlatformUtils :: Initialize' C++ Builderテストアプリ
非常に単純なVCLアプリケーション(フォーム上のボタン)を作成しました。これは、3つのリンカエラーが得られます。
Unresolved external 'xercesc_3_1::XMLPlatformUtils::Terminate()
Unresolved external 'xercesc_3_1::XMLUni::fgXercescDefaultLocale
Unresolved external 'xercesc_3_1::XMLPlatformUtils::Initialize()
私に起こる可能性のある原因は次のとおりです。
- をDLL
- を構築することは、私が対処する.defファイルを必要としないとき、私は何か間違ったことをしましたVC++の名前のマングリング?しかし、.slnは提供されていません。
- 私が使用するDLL関数のGetProcAddressを呼び出す必要はありませんか?しかし、DLL内のすべての関数のテンプレートはどこにありますか?
ここに私のテストアプリケーションのためのコードです:
#ifndef MainFrmH
#define MainFrmH
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_USE
class TMainForm : public TForm
{
__published: // IDE-managed Components
TButton *InitButton;
void __fastcall InitButtonClick(TObject *Sender);
private: // User declarations
HINSTANCE hXercesLib;
public: // User declarations
__fastcall TMainForm(TComponent* Owner);
__fastcall ~TMainForm();
};
extern PACKAGE TMainForm *MainForm;
#endif
#include <vcl.h>
#include <iostream>
#pragma hdrstop
#include "MainFrm.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
using namespace xercesc;
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
hXercesLib = NULL;
} // ctor
__fastcall TMainForm::~TMainForm()
{
if (hXercesLib)
{
XMLPlatformUtils::Terminate();
FreeLibrary(hXercesLib);
hXercesLib = NULL;
}
} // dtor
void __fastcall TMainForm::InitButtonClick(TObject *Sender)
{
if (!hXercesLib)
{
hXercesLib = LoadLibrary("xerces-c_3_1.dll");
try
{
XMLPlatformUtils::Initialize();
ShowMessage("XMLPlatformUtils::Initialize succeeded");
}
catch (Exception& e)
{
FreeLibrary(hXercesLib);
hXercesLib = NULL;
ShowMessage(e.Message);
}
}
}
ありがとう、レミー。ソリューションがDEFファイルのない__cdecl呼び出し規約を使用しているかのように見えます。そこで私はimpdef mydef.def xerces_c_3_1.dllを実行し、 "Warning ...:no exports"を受け取りました。かなり大きい手がかり!私は掘り下げて実験を続け、このビルドを正しく構築することを理解していきたいと考えています。 – Kathleen
今後このスレッドが見つかるかもしれない人のために、解決策はXercesからのビルド指示について仮定しないことでした。私はEmbarcadero CX10 SeattleコンパイラでMAKEファイルを実行している "Borland" C++のために推奨したことを行い、完璧に動作しました。 – Kathleen