Я собираюсь добавить функцию проверки орфографии в проект VCL Form C++ в Embarcadero RAD Studio XE.Использование Visual Studio DLL в Embarcadero RAD Studio XE?
До сих пор мне удалось создать приложение, которое использует hunspell в Visual Studio 2012, следуя шагам в C++ - Using HunSpell 1.3.2 with Visual Studio 2010. Поэтому первым моим подходом было повторное использование .dll, созданного с помощью компилятора VS в RAD Studio.
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
// dll path
const wchar_t* library = L"libhunspell.dll";
// hunspell constructor
extern "C" __declspec(dllimport) hunspell_initialize(char const * aff,char const * dic);
//adds a word to the loaded dictionary
extern "C" __declspec(dllimport) int add(char const *) ;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
HINSTANCE load;
try
{ load = LoadLibrary(library); }
catch(Exception &e)
{ ShowMessage(e.Message); }
if (load)
{
ShowMessage("Library Loaded!");
hunspell_initialize("de_DE.aff","de_DE.dic");
add("myword");
}
else {ShowMessage ("Library hasn't loaded!");}
}
Я могу загрузить библиотеку, однако компоновщик не может разрешить внешние функции.
Мой второй подход состоял в том, чтобы импортировать исходный код hunspell и включить «hunspell.hxx». Однако я получаю ошибку синтаксиса объявление в файле «csuitl.hxx»
фрагмент кода:
// default flags
#define DEFAULTFLAGS 65510
#define FORBIDDENWORD 65510
#define ONLYUPCASEFLAG 65511
// fopen or optional _wfopen to fix long pathname problem of WIN32
LIBHUNSPELL_DLL_EXPORTED FILE * myfopen(const char * path, const char * mode); // << error line
// convert UTF-16 characters to UTF-8
LIBHUNSPELL_DLL_EXPORTED char * u16_u8(char * dest, int size, const w_char * src, int srclen);
// convert UTF-8 characters to UTF-16
LIBHUNSPELL_DLL_EXPORTED int u8_u16(w_char * dest, int size, const char * src);
Я интересно, если я пропускаю простой способ включить Hunspell в мой проект, так как это широко используемый инструмент. Любая помощь приветствуется :)
(Hunspell документация: http://sourceforge.net/projects/hunspell/files/Hunspell/Documentation/)
Здравствуйте @ Andreas, не могли бы вы рассказать мне, что это за команда tdump? – IzonFreak