Thank you very much for replying.
I did not understood your intention. Assuming that DLLs produced by MinGW
gcc is not what you want ...
It isn't explained sufficiently by last mail, I am sorry.
I am now converting all my CL code to Scheme(Chicken, Gambit). I chose two
Schemes
for comparing the time (compiling time, run time). I almost finished
converting code
except creating the Windows DLL by Chicken and MinGW gcc.
By reference, I managed to make the Windows DLL by Gambit and MinGW gcc as
following,
Gambit-C v4.6.0
MinGW(mingw-get-inst-20110802.exe)
sample.scm
--
;; Initialize Gambit-C runtime system when sample.dll is loaded.
(c-declare #c-declare-end
#define LINKER 20_sample__
___BEGIN_C_LINKAGE
extern ___mod_or_lnk LINKER (___global_state_struct*);
___END_C_LINKAGE
___setup_params_struct setup_params;
BOOL WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID ptr)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
___setup_params_reset (setup_params);
setup_params.version = ___VERSION;
setup_params.linker = LINKER;
#if 1
setup_params.debug_settings =
(___DEBUG_SETTINGS_REPL_STDIO
___DEBUG_SETTINGS_REPL_SHIFT);
#endif
return ___setup (setup_params) == ___FIX(___NO_ERR);
case DLL_PROCESS_DETACH:
___cleanup ();
break;
}
return FALSE;
}
c-declare-end
)
;; Procedures exported by sample.dll:
(c-define (mycalc aa bb cc dd) (double double double double) double mycalc
(mycalc1 aa bb cc dd))
(define (mycalc1 aa bb cc dd)
(apply + `(,aa ,bb ,cc ,dd)))
-END
makefile
-
CDRV = E:
SFILE= sample.scm
CFILE= sample.c
LKFILE = sample_.c
TARGET = sample.dll
OBJS_DIR = obj
PROG_DIR = prog
CC = $(CDRV)/MinGW/bin/gcc
GSC = $(CDRV)/Gambit-C/v4.6.0/bin/gsc
INCLUDE = -I$(CDRV)/Gambit-C/v4.6.0/include
LIB = $(CDRV)/Gambit-C/v4.6.0/lib/libgambc.a
CFLAG
= -D_WINDOWS -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math
-fno-strict-aliasing -fwrapv -fno-common -mieee-fp
CFLAG1 = -shared
LDFLAG = -lws2_32
LDFLAG1 = -lwsock32
RM = rm
DFLG = -debug
GFLAG= -link
GFLAGS = $(DFLG) -c -o $(OBJS_DIR)
CFILES = $(addprefix $(OBJS_DIR)/, $(CFILE))
OFILES = $(addprefix $(OBJS_DIR)/, $(CFILE:.c=.o))
LOFILE = $(addprefix $(OBJS_DIR)/, $(LKFILE:.c=.o))
all : $(TARGET)
$(TARGET) : $(OFILES) $(LOFILE)
$(CC) $(CFLAG1) $(INCLUDE) -o $@ $^ $(LIB) $(LDFLAG1) $(LDFLAG)
$(OBJS_DIR)/%.o : $(OBJS_DIR)/%.c
$(CC) $(CFLAG) $(INCLUDE) -c -o $@ $
$(OBJS_DIR)/$(LKFILE) : $(CFILES)
$(GSC) $(GFLAG) $^
$(OBJS_DIR)/%.c : $(PROG_DIR)/%.scm
$(GSC) $(GFLAGS) $
clean :
-$(RM) $(OBJS_DIR)/*.o $(TARGET)
-END
In my case my Windows apprication can import dll as below,
test_call_dll.mq4
-
#import sample.dll
double mycalc (double,double,double,double);
#import
void OnStart()
{
Alert(mycalc(1,2,3,4));
}
-END
So I gess the Chicken version sample.scm might be,
sample.scm
--
;; Initialize Chicken runtime system when sample.dll is loaded.
#
#define LINKER ??_sample__
BOOL WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID ptr)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
???
? = LINKER;
??
case DLL_PROCESS_DETACH:
?
}
return FALSE;
}
#
;; Procedures exported by sample.dll:
(define-external (mycalc (double aa) (double bb) (double cc) (double dd))
double
(mycalc1 aa bb cc dd))
(define (mycalc1 aa bb cc dd)
(apply + `(,aa ,bb ,cc ,dd)))
-END
May someone who know inside Chicken be able to fill the ? part?
... you can try my
https://github.com/bazurbat/chicken-scheme next branch which can produce
Windows native DLLs using Visual Studio compiler with the help of CMake.
Be careful though as this branch contains a lot of other experimental
changes and not supported by the CHICKEN developers.
Thank you very much for your suggestion. After conversion work ends, I'll
check your system.
-Original Message-
From: Oleg Kolosov
Sent: Friday, February 13, 2015 11:18 PM
To: Ryuho Yokoyama
Cc: chicken-users@nongnu.org
Subject: Re: [Chicken-users] How to compile chicken scheme to Windows DLL?
On 13 Feb 2015, at 15:44, Ryuho Yokoyama ryu...@ybb.ne.jp wrote:
Hello,
I am attempting to compile the chicken scheme code down to C
and then compile it into a Windows DLL.
But I can not how to initialize chicken scheme runtime system
in the DllMain function.
Please someone show how to write a scheme code which produce a Windows DLL
and compile option etc.
Chicken Ver 3.4.0
MinGW(mingw-get-inst-20110802.exe)
I did not understood your intention. Assuming that DLLs produced by MinGW
gcc is not what you want