Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tclstub81.lib locks me into release build only

Closed / Fixed218734ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:04:43
OriginalBugID: 1932 Bug
Version: 8.1b3
SubmitDate: '1999-04-26'
LastModified: '1999-04-27'
Severity: SER
Status: Released
Submitter: pat
ChangedBy: stanton
OS: Windows NT
OSVersion: 4.0sp4 and MSVC++ v5
Machine: X86
FixedDate: '1999-04-27'
FixedInVersion: 8.1
ClosedDate: '1999-04-27'


Name:

David Gravereaux



Comments:

Rebuilding tclstub81.lib for all 4 combinations would seem to be the

    solution, and I'll try that now, but I should not have to rebuild

    components of Tcl to program extensions for it.

    

    I don't know what the solution is for the tclStubsPtr variable's name

    decoration.



ReproducibleScript:

The following test code cannot link with tclstub81.lib .  tclstub81.lib

    appears to have been built using the release msvcrt.dll .  I cannot

    staticly link my extension to the C run-time, either.

    

    Not only that, but tclStubsPtr is being decorated by the MSVC++

    compiler.

    

    --- begin CppTclExtTest.cpp ---

    #define WIN32_LEAN_AND_MEAN

    #include <windows.h>

    

    #define USE_TCL_STUBS

    #include "c:/progra~1/Tcl/include/tcl.h"

    #pragma comment(lib,"c:/progra~1/Tcl/lib/tclstub81.lib")

    

    BOOL WINAPI DllMain(HINSTANCE, ULONG, LPVOID) {

      return TRUE;

    }

    

    

    // forward reference

    class CTest;

    

    // used by all the Tcl commands to speed execution

    // by storing its member function location in the

    // clientdata on command creation.

    typedef struct {

      CTest *ext;

      int (CTest::*cmd)(int, struct Tcl_Obj * CONST objv[]);

    } CMDINFO, *LPCMDINFO;

    

    

    class CTest {

    public:

      CTest(Tcl_Interp *interp) : m_interp(interp) {

        Tcl_CreateObjCommand(interp, "Test::test", CmdCallback,

            CmdInfo(&CTest::TestCmd), CmdDelete);

        Tcl_PkgProvide( interp, "SillyTest", "1.0.0" );

        Tcl_CallWhenDeleted(interp, DeleteInterpHandler, (ClientData)

    this);

        Tcl_CreateExitHandler(ExitHandler, (ClientData) this);

      };

      ~CTest() {

        Tcl_DeleteExitHandler( ExitHandler, (ClientData) this );

      };

      friend int CmdCallback(ClientData, Tcl_Interp *, int, struct Tcl_Obj *

    CONST []);

      friend void CmdDelete(ClientData);

      friend Tcl_InterpDeleteProc DeleteInterpHandler;

      friend Tcl_ExitProc ExitHandler;

    private:

      inline ClientData CmdInfo (int (CTest::*cmd)(int, struct Tcl_Obj *

    CONST objv[])) {

       LPCMDINFO stuff = new CMDINFO;

        stuff->ext = this;

        stuff->cmd = cmd;

        return (ClientData) stuff;

      };

      int TestCmd (int objc, struct Tcl_Obj * CONST objv[]) {

       Tcl_Obj *resultPtr = Tcl_GetObjResult(m_interp);

       char buf[33];

    

        sprintf(buf,"%d",this);

        Tcl_AppendStringsToObj(resultPtr, "Hi there from ",buf," !", NULL);

        return TCL_OK;

      };

      Tcl_Interp *m_interp;

    };

    

    

    static void DeleteInterpHandler (ClientData clientData, Tcl_Interp

    *interp) {

     CTest *extension = (CTest *)clientData;

      delete extension;

    };

    

    static void ExitHandler (ClientData clientData) {

     CTest *extension = (CTest *)clientData;

      delete extension;

    };

    

    

    static int CmdCallback (ClientData clientData, Tcl_Interp *, 

                            int objc, struct Tcl_Obj * CONST objv[])

    {

     LPCMDINFO stuff = (LPCMDINFO)clientData;

    

      // We aleady know what the interp pointer is,

      // so don't bother with it.

    

      // Call the member function of the extension instance

      // as saved in the clientdata pointer ;)  Think of

      // this as a demultiplexor

      return ((stuff->ext)->*(stuff->cmd))(objc,objv);

    };

    

    static void CmdDelete(ClientData clientData) {

     LPCMDINFO stuff = (LPCMDINFO)clientData;

      delete stuff;

    };

    

    

    extern "C" __declspec( dllexport )

    #ifdef _DEBUG

    int CppTclExtTestd_Init (Tcl_Interp *interp) {

    #else

    int CppTclExtTest_Init (Tcl_Interp *interp) {

    #endif

      if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {

        return TCL_ERROR;

      }

      try {

        new CTest(interp);

      }

      catch (char *msg) {

        MessageBox(NULL, msg, "Test extension ERROR!",

    MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);

        return TCL_ERROR;

      }

      return TCL_OK;

    };

    --- end CppTclExtTest.cpp ---



ObservedBehavior:

--------------------Configuration: CppTclExtTest - Win32

    Debug--------------------

    Compiling...

    CppTclExtTest.cpp

    Linking...

       Creating library Debug/CppTclExtTest.lib and object

    Debug/CppTclExtTest.exp

    LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other

    libs; use /NODEFAULTLIB:library

    CppTclExtTest.obj : error LNK2001: unresolved external symbol "struct

    TclStubs *  tclStubsPtr" (?tclStubsPtr@@3PAUTclStubs@@A)

    Debug/CppTclExtTest.dll : fatal error LNK1120: 1 unresolved externals

    Error executing link.exe.

    

    CppTclExtTest.dll - 2 error(s), 1 warning(s)



DesiredBehavior:

a clean link





The name decoration issue has been resolved.

The linking issue can be resolved by using the /nodefaultlib:msvcrt flag when linking against the stub library.
04/27/1999 14:06 - stanton -
welch Closed ticket [218734ffff]. [History diff]2000-10-26 08:28:12
dgp Ticket [218734ffff]: 3 changes [History diff]2001-04-17 06:02:50
Log in (anonymous is fine) to add a comment.