From: SourceForge.net <no...@so...> - 2005-05-09 19:05:19
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=3142060 By: johnbogus I am trying to make a dll to allow tcl to interfaces to some hardware through a vendor supplied mscv dll (ljackus.dll). I have been able to write a dll which talks to tcl , but as soon as I include any code which talks to the msvc dll (#if 0 comment out), the driver will not load. -------------------------------------------------------------------------- #include <windows.h> #include <tcl.h> #ifndef DECLSPEC_EXPORT #define DECLSPEC_EXPORT __declspec(dllexport) #endif // DECLSPEC_EXPORT BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) { return TRUE; } int ljackCmdHello ( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *resultPtr; resultPtr=Tcl_GetObjResult(interp); Tcl_SetStringObj(resultPtr, "hello back at you", 17); return TCL_OK; } EXTERN_C int DECLSPEC_EXPORT Ljacktcl_Init(Tcl_Interp* interp) { #ifdef USE_TCL_STUBS Tcl_InitStubs(interp, "8.4", 0); #endif Tcl_Obj *version = Tcl_SetVar2Ex(interp, "Ljacktcl_version", NULL, Tcl_NewDoubleObj(0.1), TCL_LEAVE_ERR_MSG); if (version == NULL) return TCL_ERROR; printf("creating labjack command"); // Call Tcl_CreateObjCommand etc. Tcl_CreateObjCommand(interp, "hello", ljackCmdHello, NULL, NULL); //Tcl_CreateObjCommand(interp, "getWinVersion", ljackCmdGetWinVersion, NULL, NULL); int r = Tcl_PkgProvide(interp, "Ljacktcl", Tcl_GetString(version)); return r; } EXTERN_C int DECLSPEC_EXPORT Ljacktcl_SafeInit(Tcl_Interp* interp) { // We don't need to be specially safe so... return Ljacktcl_Init(interp); } #if 0 long _stdcall GetWinVersion(unsigned long *majorVersion, unsigned long *minorVersion, unsigned long *buildNumber, unsigned long *platformID, unsigned long *servicePackMajor, unsigned long *servicePackMinor); int ljackCmdGetWinVersion ( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { unsigned long majorVersion; unsigned long minorVersion; unsigned long buildNumber; unsigned long platformID; unsigned long servicePackMajor; unsigned long servicePackMinor; Tcl_Obj *resultPtr, *temp; resultPtr=Tcl_GetObjResult(interp); if (objc != 1) { Tcl_WrongNumArgs(interp,0,objv,""); return TCL_ERROR; } if(GetWinVersion( &majorVersion, &minorVersion, &buildNumber, &platformID, &servicePackMajor, &servicePackMinor)) { Tcl_SetStringObj(resultPtr,"library routine error ",-1); return TCL_ERROR; } Tcl_SetListObj(resultPtr, 0, NULL); temp = Tcl_NewLongObj(majorVersion); Tcl_ListObjAppendElement(interp, resultPtr,temp ); Tcl_SetLongObj(temp, minorVersion); Tcl_ListObjAppendElement(interp, resultPtr,temp ); Tcl_SetLongObj(temp, buildNumber); Tcl_ListObjAppendElement(interp, resultPtr,temp ); Tcl_SetLongObj(temp, platformID); Tcl_ListObjAppendElement(interp, resultPtr,temp ); Tcl_SetLongObj(temp, servicePackMajor); Tcl_ListObjAppendElement(interp, resultPtr,temp ); Tcl_SetLongObj(temp, servicePackMinor); Tcl_ListObjAppendElement(interp, resultPtr,temp ); return TCL_OK; } //#endif -------------------------------------------------------------------------- PROJ_ROOT = ljacktcl DLL =$(PROJ_ROOT).dll DEFFILE =$(PROJ_ROOT).def DLLWRAP =dllwrap CC = gcc LIBS = -ltcl84 -lm -lljackuw INCLUDES = -Ic:/Tcl/include SRCS = $(PROJ_ROOT).c OBJS =$(SRCS:.c=.o) CFLAGS = -g -Wall LDFLAGS =-LC:/Tcl/lib -L. WRAPFLAGS =--driver-name $(CC) --def $(DEFFILE) all: $(DLL) $(DLL): $(OBJS) ljackuw.a $(DLLWRAP) $(WRAPFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) %.o: %.c ${CC} ${CFLAGS} ${INCLUDES} -c $< -o $@ depend: makedepend ${SRCS} clean: rm *.o core *~ $(DLL) *.bak ljackuw.a libljackuw.a # rm *.o core *~ $(DLL) *.bak ljackuw.a libljackuw.a ljackuw.def ljackuw.def: pexports c:/windows/system32/ljackuw.dll | sed "s/^_//" > ljackuw.def # hand edit afterwards to add @24,etc sufixes ljackuw.a: ljackuw.def dlltool --dllname c:/windows/system32/ljackuw.dll --def ljackuw.def --output-lib libljackuw.a # dlltool -U -d ljackuw.def -l ljackuw.a ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=7134 |