I've finally gotten the C# binding examples to run both on Linux and Windows. This means, of course, that one should be able to write C# code on either platform and have the resulting application also run on either. (At least at this point the C# examples packaged with the Sword
distribution run on both platforms using identical C# code.)

I've written a tutorial outlining the steps needed to accomplish this. That's attached as a
text file. Would it be appropriate to add this to the developer's wiki?

Be blessed,
Jon

Making Sword C# Bindings for windows

1. Set up Sword for windows according to these instructions:
http://crosswire.org/wiki/Tutorial:Compiling_%26_Installing_SWORD_on_Windows

Except, stop before making libsword.sln, you will need to make some changes 
before
the project will build successfully.

2. Open \sword\sword\lib\vcppmake\libsword.sln in VS2013 and allow the project 
to
be converted.

3. Open the project properties window

        3.1 Under the C/C++ tab General, edit additional include directories
                Change icu-sword to icu
        
        3.2 Under the Linker tab General, edit additional library directories
                Change 
libcurl-vc10-x86-release-static-ipv6-sspi-spnego-winssl/lib to
                           
libcurl-vc-x86-release-static-ipv6-sspi-spnego-winssl/lib
                           
                Change icu-sword/lib to icu/lib
                
4. In the Solution Explorer window, drag the file: sword\bindings\flatapi.cpp
into the solution.

5. Open flatapi.h 

        5.1 Replace all ' * SWDLLEXPORT ' with ' SWDLLEXPORT * ' (without the 
quotes)
        
        5.2 Replace all ' ** SWDLLEXPORT ' with ' SWDLLEXPORT ** ' (without the 
quotes)
        
        5.3 Declare the following function:
        
        SWHANDLE SWDLLEXPORT org_crosswire_sword_SWMgr_newWithPath(const char 
*thePath);

        
6. Open flatapi.cpp

        6.1 Make the replacements as in step 5
        
        6.2 Change all ::clearModInfo to clearTheModInfo (remove the colons and 
rename)
        
        6.3 Change the declaration of clearModInfo in the unnamed namespace to 
clearTheModInfo
        
        6.4 Define the function in 5.3 above:
        
        SWHANDLE SWDLLEXPORT org_crosswire_sword_SWMgr_newWithPath(const char 
*thePath) {
                SWConfig *sysConf = new SWConfig(thePath);
                return (SWHANDLE) new HandleSWMgr(new WebMgr(sysConf));
        }
        
7. At this point, libsword.sln should make without errors - either release or 
debug.

8. In the Sword distribution, there is a bindings directory having a csharp 
directory.
In that directory, edit the file NativeMethods.cs:

        8.1 In the NativeMethods class the DLLNAME changes from libsword.so to 
libsword.dll
        
        8.2 In the NativeMethods class change:
                [DllImport(DLLNAME)] to
                [DllImport(DLLNAME, CallingConvention=CallingConvention.Cdecl)]
                
9. Put all of the dlls in the sword project where C# can find them. Quick and 
dirty is to
copy them all to the bin directory for the executable you will build. You may 
need the 
following dlls (I don't know yet which dlls do what, so I've included them all 
from the
Windows build of the Sword distribution. This list works, a lesser list may be 
sufficient.):

        icule53.dll             clucene-core.dll        icudt53.dll             
icuuc53.dll
    liblzma.dll         icuio53.dll                     icuin53.dll             
binding.dll
    icutu53.dll         iculx53.dll                     clucene-shared.dll
    libsword.dll        libbz2.dll
        
10. Figure out where you want your data files and edit sword.conf to point to 
that 
directory. Also put sword.conf somewhere reasonable.

11. In sword\bindings\csharp\examples edit LookupExample.cs
        using (var manager = new manager()) //changes to
        using (var manager = new manager(@"path to sword.conf"))
        
_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to