Mail Archives: cygwin/2004/09/17/11:22:09
I'm having problems executing file I/O and calling executables from
a DLL? I know this sounds simple, and this works fine under Excel,
but I'm having problems doing this with TradeStation.
Is there anything I should know about changes in paths, root directories,
etc., that can occur under different applications?
I have modified a simple code to prepare a DLL from a fairly well-known
tool, dllhelpers,
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html
and I have produced an equally good DLL using a Makefile enclosed.
I've just added a call to another independent executable. This works
just fine (using either the more standard dllhelper way or using my
own Makefile) under Excel using the dllhelpers-prepared dlltest.xls.
Here's some simple code I prepared to explain what I've done. I'm using
*all* the most current Curr downloads via setup.exe from cygwin.com.
Makefile for cdll.c:
------------8<------------ top cut -> bottom ------------->8------------
DLL_OPTION=-mrtd # I found this necessary for DLLs to work
CYGWIN_OPTION=-mno-cygwin $(DLL_OPTION)
CC = gcc
CDEBUGFLAGS = -g -O -Wall
CFLAGS = $(CDEBUGFLAGS) $(CYGWIN_OPTION)
LDFLAGS = $(CYGWIN_OPTION)
obj_libs = cdll.o
dllmodule = cdll
dependency_libs = -lm
all:
$(CC) $(CFLAGS) -c -o ${obj_libs} cdll.c
$(CC) $(CFLAGS) -mrtd -shared -o ${dllmodule}.dll \
-Wl,--out-implib=${dllmodule}.lib \
-Wl,--compat-implib \
-Wl,--add-stdcall-alias \
-Wl,--enable-stdcall-fixup \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--whole-archive ${obj_libs} \
-Wl,--export-all-symbols \
-Wl,--output-def=${dllmodule}.def \
-Wl,--no-whole-archive ${dependency_libs}
------------8<------------ bottom cut <- top ------------->8------------
cdll.c (In Tradestation, you have to change double->float):
------------8<------------ top cut -> bottom ------------->8------------
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
double dll_double_square (double d);
double
dll_double_square (double d)
{
char trd_comm[200];
FILE *ptr_comm;
/* I tried this with a system() call, but it still doesn't work when
dll_double_square is called in TradeStation */
sprintf (trd_comm, "run_trd.exe");
ptr_comm = popen (trd_comm, "r");
pclose (ptr_comm);
return d * d;
}
------------8<------------ bottom cut <- top ------------->8------------
Makefile for trd.c:
------------8<------------ top cut -> bottom ------------->8------------
CYGWIN_OPTION=-mno-cygwin
CC = gcc
CDEBUGFLAGS = -g -O -Wall
CFLAGS = $(CDEBUGFLAGS) $(CYGWIN_OPTION)
LDFLAGS = $(CYGWIN_OPTION)
obj_libs = trd.o
all: $(obj_libs)
@$(CC) $(LDFLAGS) -o run_trd.exe $(obj_libs) -lm
------------8<------------ bottom cut <- top ------------->8------------
trd.c:
------------8<------------ top cut -> bottom ------------->8------------
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ();
int
main ()
{
char trd_comm[50];
FILE *ptr_comm;
sprintf (trd_comm, "mkdir ..\\IO\\%s", "test_dir");
ptr_comm = popen (trd_comm, "r");
pclose (ptr_comm);
printf ("mkdir test_dir\n");
return 0;
}
------------8<------------ bottom cut <- top ------------->8------------
I have the same non-results in TradeStation, but OK results in Excel,
if I simply create the test_dir within cdll.c, e.g., *not* calling any
other executable.
In TradeStation, the code returns just fine, and goes on to do other
stuff, but the commands I cite just are not being executed?
I also tried including explicit paths, e.g., prefacing the executable
and file with c:\cygwin\..., and not even using any relative paths like
"..", but with no positive effect.
Thanks.
Lester
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -