"System Environment"
Windows Server 2008 R2,haskell Platform 2013.2.0.0,GHC 7.6.3,cabal 1.16.0
"Action Steps"
1. Install Windows version Haskell Platform (does not support Windows Server), Haskell Platform integrates cabal (equivalent to. NET Msbuild+nuget), GHC (Glasgow Haskell Compiler,haskell compiler)
2. Write the Haskell code in the. hs file, add foreign export ccall in the code, and the sample code is as follows:
3. Write C code in the. c file with the following code:
#include <windows.h>
#include <Rts.h>
extern void __stginit_libpandoc (void);
BOOL stdcall DllMain (HANDLE hmodule, DWORD reason, void* reserved)
{
static char* args[] = {"Libpandoc", Null};
if (reason = = Dll_process_attach) {
Startuphaskell (1, args, __stginit_libpandoc);
}
return TRUE;
}
4. Write cabal configuration files in. cabal files, such as:
Name: libpandoc
Version: 0.5
cabal-version: >= 1.2
build-type:
Simple Executable Libpandoc.dll
If os (Windows)
cpp-options: -dwin32
Extensions: Foreignfunctioninterface
hs-source-dirs: src
include-dirs: src
c-sources: src/ PANDOC.C
install-includes: pandoc.h
main-is: libpandoc.hs
ghc-options: - No-hs-main-optl-shared-optl-s
5. Run the command Cabal build on the folder where the Haskell project is located, and then generate the header file when the compilation succeeds, such as Build\libpandoc.dll\libpandoc.dll-tmp\libpandoc_stub.h
#include "HsFFI.h"
#ifdef __cplusplus
extern "C" {
#endif
extern hsptr markdowntohtml (hsptr A1); c31/> #ifdef __cplusplus
}
#endif