Re: C++/TCL Need Solution to Compile Error c2784
- From: JesusChuyCampos@xxxxxxxxx
- Date: 17 Apr 2007 17:55:56 -0700
On Apr 16, 8:45 pm, David Gravereaux <davyg...@xxxxxxxxx> wrote:
I unfortunately have way too much to comment on. So here's my post again (that
google didn't pick up) of my stab at those two.
Let's hand roll those two. I'll assume the return code is an error code, with
zero being success and *handle is set by the function on return. The commands in
the interp will be [jnior::Connect <ip> <port> <user> <pass>], it returns the
handle of the connection. [jnior::Disconnect <handle>] will do the disconnect
called with the handle returned from Connect.
command to compile would be something like this:
cl -nologo -MD -IC:\tcl\include jnior_tcl.c -link -dll -out:jniortcl.dll
-libpath:C:\Tcl\lib jnior300.lib
--- jnior_tcl.c -----
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <limits.h>
#include "jnior_300.h"
#define USE_TCL_STUBS
#include "tcl.h"
/* Mark this .obj as needing Tcl's Stubs library. */
#pragma comment(lib, "tclstub" \
STRINGIFY(JOIN(TCL_MAJOR_VERSION,TCL_MINOR_VERSION)) ".lib")
/* Protos */
__declspec(dllexport) Tcl_AppInitProc Jniortcl_Init;
Tcl_ObjCmdProc ConnectCmd;
Tcl_ObjCmdProc DisconnectCmd;
/* Optional, but explicit. */
BOOL WINAPI
DllMain (HINSTANCE hInst, ULONG ulReason, LPVOID lpReserved)
{
if (ulReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hInst);
return TRUE;
}
int
Jniortcl_Init (Tcl_Interp *interp)
{
#ifdef USE_TCL_STUBS
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
return TCL_ERROR;
}
#endif
# define MAKECMD(name) \
Tcl_CreateObjCommand(interp, STRINGIFY(JOIN(jnior::,name)), \
JOIN(name,Cmd), 0L, 0L);
MAKECMD(Connect);
MAKECMD(Disconnect);
Tcl_PkgProvide(interp, "jnior", "0.1");
return TCL_OK;
}
int
ConnectCmd (ClientData clientData, Tcl_Interp *interp,
int objc, struct Tcl_Obj * CONST * objv)
{
long ok, handle;
char *ip, *username, *password;
unsigned short port;
int iPort;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 1, objv, "ip port user pass");
return TCL_ERROR;
}
ip = Tcl_GetString(objv[1]);
if (Tcl_GetIntFromObj(interp, objv[2], &iPort) != TCL_OK) {
return TCL_ERROR;
}
if (iPort < 0 || iPort > USHRT_MAX) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("port out-of-range",-1));
return TCL_ERROR;
}
port = (unsigned short) iPort;
user_name = Tcl_GetString(objv[3]);
password = Tcl_GetString(objv[4]);
ok = Connect(ip, port, &handle, user_name, password);
if (ok == 0) {
Tcl_SetObjResult(interp, Tcl_NewLongObj(handle));
return TCL_OK;
} else {
/* handle error condition here */
return TCL_ERROR;
}
}
int
DisconnectCmd (ClientData clientData, Tcl_Interp *interp,
int objc, struct Tcl_Obj * CONST * objv)
{
long ok, handle;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "handle");
return TCL_ERROR;
}
if (Tcl_GetLongFromObj(interp, objv[1], &handle) != TCL_OK) {
return TCL_ERROR;
}
ok = Disconnect(handle);
if (ok == 0) {
/* success */
return TCL_OK;
}
return TCL_ERROR;
}
--
How many boards would the Mongols hoard if the Mongol hordes got bored?
-- Calvin
signature.asc
1KDownload
David,
I got one more question. Do I have to tell the compiler to load the
jnior.dll or does it have to be part of the source code. Here are the
error messages that I'm getting. What compiler are you using?
error04.txt
===================================== START
jnior310tcl2.c
c:\program files\tcl_tk\tcl_c_api2\jnior_300.h(19) : warning C4031:
second formal parameter list longer than the first list
c:\program files\tcl_tk\tcl_c_api2\jnior_300.h(19) : warning C4028:
formal parameter 1 different from declaration
c:\program files\tcl_tk\tcl_c_api2\jnior_300.h(19) : warning C4142:
benign redefinition of type
c:\program files\tcl_tk\tcl_c_api2\jnior_300.h(19) : warning C4273:
'GetVersion' : inconsistent dll linkage
C:\Program Files\Microsoft Visual Studio\VC98\include
\winbase.h(1116) : see previous definition of 'GetVersion'
Creating library jniortcl2.lib and object jniortcl2.exp
jnior310tcl2.obj : error LNK2019: unresolved external symbol
_Connect@20 referenced in function _ConnectCmd
jnior310tcl2.obj : error LNK2019: unresolved external symbol
_Disconnect@4 referenced in function _DisconnectCmd
jniortcl2.dll : fatal error LNK1120: 2 unresolved externals
===================================== STOP
I guess my biggest problem is with the compiler. I got IT to re-
installed MS Visual Studio 6 (because we have a spare license), and
that just gave me more problems, and I then had IT re-installed MS VC+
+ 2005 "Express Edition", since it has a 30 day trial, but it is
missing the "window.h", so now I'm trying to link libraries from both
compilers.
-JC
.
- Follow-Ups:
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- References:
- C++/TCL Need Solution to Compile Error c2784
- From: JesusChuyCampos
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: JesusChuyCampos
- Re: C++/TCL Need Solution to Compile Error c2784
- From: Christian Gollwitzer
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: Alexandre Ferrieux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: JesusChuyCampos
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- Re: C++/TCL Need Solution to Compile Error c2784
- From: JesusChuyCampos
- Re: C++/TCL Need Solution to Compile Error c2784
- From: David Gravereaux
- C++/TCL Need Solution to Compile Error c2784
- Prev by Date: Re: Michael Cleverly's "burrow" ...
- Next by Date: Re: C++/TCL Need Solution to Compile Error c2784
- Previous by thread: Re: C++/TCL Need Solution to Compile Error c2784
- Next by thread: Re: C++/TCL Need Solution to Compile Error c2784
- Index(es):
Relevant Pages
|