I am attempting to use Hunspell DLL in C++ Builder but have nothing but troubles.
So I try to resort to compiling as static library. But even that doesn't go smooth. The steps I did so far:
downloaded the latest Hunspell from https://github.com/hunspell/hunspell/releases
unzipped and created in C++ Builder - New / Other / Static Library
right clicked and added all *.cxx files from src/hunspell
folder
Clicked Build
The error which comes up is:
[BCC32 Error] cwchar(33): E2141 Declaration syntax error
cwchar is a file which is part of C++ Builder and not Hunspell as it seems (which only includes it).
Any help in building static hunspell lib (or even DLL) from C++ Builder appreciated.
Thanks in advance!
Edit: I was able to progress further by using more recent C++ Builder Berlin (the above error was in 2010 version) but it still reported linker errors, so I ended up using the DLL - see the answer.
As Remy Lebeau and Rudy Velthuis pointed out it turned out to be easier to use DLL instead. I've also discovered a few more tricks along the way which I will describe below.
1) when trying to create static lib file using C++ Builder (Berlin), it turned out that the current hunspell-1.6.2.zip is not compiling without errors. However, the hunspell-master.zip which is a clone of the SVN master, it at least compiled, although there were some linker errors - but I figured that master version is better to use as a base for building the DLL. So I used the current master version (https://github.com/hunspell/hunspell).
2) used Visual Studio 2015 Community to build the DLL - libhunspell.dll. To avoid dependencies, I used the /MT
option in the compiler. I had many problems using the version of the DLL which was dependent on VC++ 2015 Redistributable ("Access Violation" errors immediately after calling some DLL functions), so statically linking the Redistributable to remove the dependency, all of these problems magically disappeared. Even though the compiler reported some warnings which is probably another question, it did manage to build the DLL.
3) created import library using implib -a -c -f libhunspell.lib libhunspell.dll
4) finally, linked to the .cpp file using #pragma comment(lib, "libhunspell.lib")
(for older RAD Studio versions) or #pragma comment(lib, "libhunspell")
for newer RAD Studio versions which support 64bit compiler). Another option is to add the lib to the project instead of the #pragma
statement.