[sword-devel] compiling sword library with CLucene

Matthew Talbert ransom1982 at gmail.com
Sat Mar 7 22:46:43 MST 2009

On Sat, Mar 7, 2009 at 11:48 PM, Greg Hellings <greg.hellings at gmail.com> wrote:
> MMital,
> I had the same problem linking CLucene into Bibletime.  The solution
> was simple, although not self-evident.  I'm going to guess that you
> are building the CLucene library with the provided project file in
> clucene-core-0.9.21b\win32.  This is, strangely, not an overly
> effective way to do it.  Download and install CMake for Windows from
> the CMake website and run it, telling it to configure in the CLucene
> directory.  Then open the file in src\CLucene\clucene-core.vcproj and
> build with that.  The target build of the library will be
> src\CLucene\debug\clucene-core.lib and
> src\CLucene\release\clucene-core.lib.  Then point the SWORD sources to
> include files from src\ and it should pickup the proper configuration
> files src\CLucene\clucene-config.h (a file which is created by CMake
> from the clucene-config.h.cmake file and is actually in-touch with the
> settings of the built library).  Obviously you'll need to add the
> LUCENE_AVAILABLE or whatever pre-processor macro to the SWORD project
> and also add the include directories and point the proper version of
> the clucene-core.lib library.  We were missing most of the same issues
> with deprecated versions of the functions in BibleTime and it wasn't
> until I realized that the VC Project files that were included in win32
> had some misconfiguration problems that the CMake-generated VC Project
> files had correct that I was able to overcome most of those problems.
> It should also prevent you from having to manually #define TCHAR, but
> I don't know that for sure.  Happy hacking!
> --Greg

I'm not actually sure that Greg's solution will work in this
situation. It depends on whether BibleTime is using the same functions
in the same way sword is. At the root of the issue is that TCHAR can
be defined as either char or wchar_t, depending on how you configure
it. In particular, if you define "_UNICODE" in the pre-processor, that
defines TCHAR as wchar_t. For the functions that sword is using, it is
critical that TCHAR be defined as wchar_t, *not* as char. I suspect
that BT may require the opposite, although I don't know for sure. At
any rate, the standard solution for clucene will build with TCHAR
defined as wchar_t, which means that you will have linking problems if
TCHAR is defined as CHAR for sword. I'm actually a little surprised
that it compiled.

In the end, I really think you want TCHAR to be wchar_t, even if the
other way is possible. This is because I believe that defining TCHAR
as char for clucene will force it into ANSI mode instead of Unicode,
which means indexing, etc may not work for non-latin texts.

While I'm 95% sure of everything above, I'm actually attempting this
myself, and still have a couple of linking problems. I believe I know
the solution, but have not yet tried it.


More information about the sword-devel mailing list