loading dll's in tcl8.2 and tcl8.3 
Author Message
 loading dll's in tcl8.2 and tcl8.3

Hi,

we have created here a tcl package which uses dll written in plain C and
compiled with MSVC6.0 and tcl8.2. In these dll tcl.h is included.
When transferring these package to another pc, which has tcl8.3 the
dll's don't load anymore. After recompiling the problem was solved.
Is this a "normal" behaviour that you have to recompile for a new
tcl-version, or is there any solution to this problem.

Thanks,
Jurgen
--
Jurgen Meirlaen                         Coupure Links 653
Biomath department,                     9000 Gent
Ghent University,                       Tel:+32 (0)9/264.59.37



Sun, 20 Jul 2003 00:31:28 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:
> Hi,

> we have created here a tcl package which uses dll written in plain C and
> compiled with MSVC6.0 and tcl8.2. In these dll tcl.h is included.
> When transferring these package to another pc, which has tcl8.3 the
> dll's don't load anymore. After recompiling the problem was solved.
> Is this a "normal" behaviour that you have to recompile for a new
> tcl-version, or is there any solution to this problem.

> Thanks,
> Jurgen

It may be because you don't use stubs to compile your extension. Using stubs
enables a compiled extension to work with any (stub-enabled) version of Tcl
without needing to recompile it.

You can find information about stubs on http://dev.scriptics.com/doc/howto/stubs.html

L

--
MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

Laurent Duperval                 "Montreal winters are an intelligence test,
                                         and we who are here have failed it."

Penguin Power!         ***Nothing I say reflects the views of my employer***



Sun, 20 Jul 2003 01:04:24 GMT  
 loading dll's in tcl8.2 and tcl8.3
Let me be more specific, the problem is that your DLL was
probably linked directly against tcl82.dll using the normal
DLL linking methodology.  The problem is that by having the
version number in the DLL name, if you move to a machine
that has Tcl 8.3, it does not have tcl82.dll but rather
tcl83.dll.  The DLL loading mechanism was told at link time
to find tcl82.dll, and does not (correctly, and by design)
look for "newer" tcl83.dll (it does not know that the 82 and
83 are version numbers).

The Tcl Stubs mechanism, which was added to the Tcl core in
8.1, allows you to link in a static "stub" lib into your DLL,
and NOT link against the Tcl DLL.  At load time, Tcl passes
a pointer down to your DLL through a known entry point,
which fills in the references to the functions in the Tcl DLL
so that your DLL can call them.  It's very fast, faster
than normal DLL symbol resolution.  On Unix, it's definitely
smaller.

What's nice about stubs is that you can upgrade Tcl to
any version of 8.x (after 8.1) without needing to rebuild
your DLL.  If someone changes an API, they can add a fake
version (backwards compatible) in the slot designated
for the original API and add the new version to a different
slot.  The old DLLs will look in the old slot, new ones
will look in the new slot.

-- Scott



Quote:

> > Hi,

> > we have created here a tcl package which uses dll written in plain
C and
> > compiled with MSVC6.0 and tcl8.2. In these dll tcl.h is included.
> > When transferring these package to another pc, which has tcl8.3 the
> > dll's don't load anymore. After recompiling the problem was solved.
> > Is this a "normal" behaviour that you have to recompile for a new
> > tcl-version, or is there any solution to this problem.

> > Thanks,
> > Jurgen

> It may be because you don't use stubs to compile your extension.
Using stubs
> enables a compiled extension to work with any (stub-enabled) version
of Tcl
> without needing to recompile it.

> You can find information about stubs on

http://dev.scriptics.com/doc/howto/stubs.html

- Show quoted text -

Quote:

> L

> --
> MY EMAIL ADDRESS HAS CHANGED --> UPDATE YOUR ADDRESSBOOK

> Laurent Duperval                 "Montreal winters are an
intelligence test,
>                                          and we who are here have
failed it."

Camilli
> Penguin Power!         ***Nothing I say reflects the views of my
employer***

Sent via Deja.com
http://www.deja.com/


Sun, 20 Jul 2003 01:51:52 GMT  
 loading dll's in tcl8.2 and tcl8.3
[snip use tcl stubs explanation]

Quote:

> > You can find information about stubs on
> http://dev.scriptics.com/doc/howto/stubs.html

I used the information on this website (USE_TCL_STUBS, link with
tclstub82.lib)but while linking I got a conflict with the defaultlib
MSVCRT
I excluded this from the linking process, and the linking is finished
without errors. However loading the created dll, the wish crashed and
sometimes even I have to reboot to get rid of the crashed wish window.
IS MSVCRT a very important library and why does it conflict with
tclstub82.lib as well as with  tclstub83.lib. Any solutions to this
problem.

Thanks,
Jurgen

--
Jurgen Meirlaen                         Coupure Links 653
Biomath department,                     9000 Gent
Ghent University,                       Tel:+32 (0)9/264.59.37



Sun, 20 Jul 2003 17:57:58 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

>[snip use tcl stubs explanation]

>> > You can find information about stubs on
>> http://dev.scriptics.com/doc/howto/stubs.html

>I used the information on this website (USE_TCL_STUBS, link with
>tclstub82.lib)but while linking I got a conflict with the defaultlib
>MSVCRT
>I excluded this from the linking process, and the linking is finished
>without errors. However loading the created dll, the wish crashed and
>sometimes even I have to reboot to get rid of the crashed wish window.
>IS MSVCRT a very important library and why does it conflict with
>tclstub82.lib as well as with  tclstub83.lib. Any solutions to this
>problem.

>Thanks,
>Jurgen

That is a very interesting limitation of microsoft's compiler.  link with the
switch '-nodefaultlib:msvcrt.lib' as you're happening to be doing a debug build
or using libcmt.lib or both.

If tclStubLib.c could have been compiled without a c-runtime reference this
wouldn't be needed, but alas cl.exe won't let you.  Best solution to this is to
compile tclStubLib.c for a listings output, edit out the 'includelib msvcrt.lib'
from the resulting tclStubLib.asm file, then make it into a COFF obj with MASM,
then package it up with lib.exe :)

problem solved!

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 18:29:17 GMT  
 loading dll's in tcl8.2 and tcl8.3
I should eat my own dog food.  'includelib msvcrt.lib'  wasn't actually
specified so there's no need sed/grep, but there's a collision on a constant
that doesn't need to be public so this doesn't work, but it's very close.


ed in tclBasic.obj

ined in tclBasic.obj; second definition ignored

cvs -z1 diff makefile.vc (in directory D:\TclPro_WS\tcl\win\)
Index: makefile.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/makefile.vc,v
retrieving revision 1.59
diff -c -r1.59 makefile.vc
*** makefile.vc 2000/11/03 21:23:28     1.59
--- makefile.vc 2001/01/31 12:44:32
***************
*** 490,497 ****
  # The following objects are part of the stub library and should not
  # be built as DLL objects but none of the symbols should be exported

! $(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c

  # Dedependency rules
--- 490,502 ----
  # The following objects are part of the stub library and should not
  # be built as DLL objects but none of the symbols should be exported

! $(TMPDIR)\tclStubLib.asm : $(GENERICDIR)\tclStubLib.c


!
! $(TMPDIR)\tclStubLib.obj : $(TMPDIR)\tclStubLib.asm

!

  # Dedependency rules

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 20:56:19 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

>If tclStubLib.c could have been compiled without a c-runtime reference this
>wouldn't be needed, but alas cl.exe won't let you.

I was not correct.  I never read about the -Z1 option.  It apparently removes
the adding of a c-runtime to the .obj .  I have yet to try it, but it looks good
from the docs.  It was dog food for dinner tonight :)

Index: makefile.vc
===================================================================
RCS file: /cvsroot/tcl/tcl/win/makefile.vc,v
retrieving revision 1.59
diff -c -r1.59 makefile.vc
*** makefile.vc 2000/11/03 21:23:28     1.59
--- makefile.vc 2001/01/31 13:13:09
***************
*** 491,497 ****
  # be built as DLL objects but none of the symbols should be exported

  $(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c

  # Dedependency rules
--- 491,497 ----
  # be built as DLL objects but none of the symbols should be exported

  $(TMPDIR)\tclStubLib.obj : $(GENERICDIR)\tclStubLib.c

  # Dedependency rules

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 21:16:37 GMT  
 loading dll's in tcl8.2 and tcl8.3
David,

Quote:
> I should eat my own dog food.  'includelib msvcrt.lib'  wasn't actually
> specified so there's no need sed/grep, but there's a collision on a constant
> that doesn't need to be public so this doesn't work, but it's very close.


> ed in tclBasic.obj

> ined in tclBasic.obj; second definition ignored

> cvs -z1 diff makefile.vc (in directory D:\TclPro_WS\tcl\win\)
> Index: makefile.vc

[snip result of diff]

I don't understand at all what this means for my problem (actually I'm
not convenient with this types of builds). Can you please explain what
it means in general or for me ? Should I get the tcl source and
recompile tclStubLib for visual c. I only did binary installs on the
win32 platform, so all this is very new to me (willing to learn of
course, but I definitely need more help).

Thanks,
Jurgen

--
Jurgen Meirlaen                         Coupure Links 653
Biomath department,                     9000 Gent
Ghent University,                       Tel:+32 (0)9/264.59.37



Sun, 20 Jul 2003 21:17:06 GMT  
 loading dll's in tcl8.2 and tcl8.3


| [snip use tcl stubs explanation]
|
| >
| > > You can find information about stubs on
| > http://dev.scriptics.com/doc/howto/stubs.html
| > >
|
| I used the information on this website (USE_TCL_STUBS, link with
| tclstub82.lib)but while linking I got a conflict with the defaultlib
| MSVCRT
| I excluded this from the linking process, and the linking is finished
| without errors. However loading the created dll, the wish crashed and
| sometimes even I have to reboot to get rid of the crashed wish window.
| IS MSVCRT a very important library and why does it conflict with
| tclstub82.lib as well as with  tclstub83.lib. Any solutions to this
| problem.
|
| Thanks,
| Jurgen

Jurgen,
Try ignoring 'LIBC' (if you are single threading) or 'LIBCMT' (if you are
multi-threading), that should hopefully fix your problem.

Find it in.
In Project Settings Dialog/Link Tab/Input combo/Ignore Libaries field

Tom Wilkason



Sun, 20 Jul 2003 21:50:57 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

>Can you please explain what
>it means in general or for me ?

add '-nodefaultlib:msvcrt.lib' to your link line or add this to your C code
after including tcl.h:

#if defined(_MSC_VER) && defined(USE_TCL_STUBS)
    // mark this .obj as needing tcl's Stubs library
#   pragma comment(lib,
STRINGIFY(JOIN(tclstub,JOIN(TCL_MAJOR_VERSION,JOIN(TCL_MINOR_VERSION,.lib)))))
#   if !defined(_MT) || !defined(_DLL) || defined(_DEBUG)
        // the requirement for msvcrt.lib from tclstubXX.lib should
        // be removed.
#       pragma comment(linker, "-nodefaultlib:msvcrt.lib")
#   endif
#endif

The logic might be off, but it's close.

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 21:54:07 GMT  
 loading dll's in tcl8.2 and tcl8.3
Tom,

Quote:
> | I used the information on this website (USE_TCL_STUBS, link with
> | tclstub82.lib)but while linking I got a conflict with the defaultlib
> | MSVCRT
> | I excluded this from the linking process, and the linking is finished
> | without errors. However loading the created dll, the wish crashed and
> | sometimes even I have to reboot to get rid of the crashed wish window.
> | IS MSVCRT a very important library and why does it conflict with
> | tclstub82.lib as well as with  tclstub83.lib. Any solutions to this
> | problem.
> Try ignoring 'LIBC' (if you are single threading) or 'LIBCMT' (if you are
> multi-threading), that should hopefully fix your problem.

Ignoring the LIBCMT instead of the MSVCRT solved again the problem of
the linking process in MSVC, but when loading the dll in a wish, the
wish performed an illegal operation and was shut down.
Anything else I could try ? (using the borland compiler ?? what command
lines ??)

Thanks
Jurgen

--
Jurgen Meirlaen                         Coupure Links 653
Biomath department,                     9000 Gent
Ghent University,                       Tel:+32 (0)9/264.59.37



Sun, 20 Jul 2003 22:09:56 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

>I don't understand at all what this means for my problem (actually I'm
>not convenient with this types of builds). Can you please explain what
>it means in general or for me ?

Ever since the beginning of Stubs, the windows build of tclstub8X.lib has been
broken.  In compiling tclStubLib.c, cl.exe was adding a requirement for linking
with msvcrt.lib (aka /MD compiler switch).  If you compile your extension for
symbols, there's a conflict with msvcrtd.lib that the linker will happily barf
about.  Also, it could be possible that one might want to use libcmt.lib and the
debug flavor of that as well (completely valid for applications and special
libraries that load into the process before Tcl).  That would make for ALOT of
flavors of one silly .obj/.lib file :)

Removing tclstub8X.lib's requirement for msvcrt.lib has always been a hack job
for me in my apps, and tonight was an awakening discovering the -Z1 compiler
option.  I added the patch to the BugDB on sourceforge, so it's doc'd.

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 22:20:08 GMT  
 loading dll's in tcl8.2 and tcl8.3
David,

Quote:
> add '-nodefaultlib:msvcrt.lib' to your link line or add this to your C code
> after including tcl.h:

I tried already before this post, the linking goes ok, but when loading
the dll, the wish performes an illegal operation and is shut down.

Quote:

> #if defined(_MSC_VER) && defined(USE_TCL_STUBS)
>     // mark this .obj as needing tcl's Stubs library
> #   pragma comment(lib,
> STRINGIFY(JOIN(tclstub,JOIN(TCL_MAJOR_VERSION,JOIN(TCL_MINOR_VERSION,.lib)))))
> #   if !defined(_MT) || !defined(_DLL) || defined(_DEBUG)
>         // the requirement for msvcrt.lib from tclstubXX.lib should
>         // be removed.
> #       pragma comment(linker, "-nodefaultlib:msvcrt.lib")
> #   endif
> #endif

> The logic might be off, but it's close.

Same result as above, linking ok, loading results in crash of the wish.

Anything else ?

Thanks,
Jurgen

--
Jurgen Meirlaen                         Coupure Links 653
Biomath department,                     9000 Gent
Ghent University,                       Tel:+32 (0)9/264.59.37



Sun, 20 Jul 2003 22:24:30 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

>Same result as above, linking ok, loading results in crash of the wish.

>Anything else ?

do you have this in your <dllname>_Init function before ALL other Tcl_* funcs?:

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

Quote:
}

Besides that, if it doesn't work, is to build for symbols and press F5.

--

  http://dev.scriptics.com/doc/integration.html#Tcl



Sun, 20 Jul 2003 22:37:24 GMT  
 loading dll's in tcl8.2 and tcl8.3

Quote:

> Ignoring the LIBCMT instead of the MSVCRT solved again the problem of
> the linking process in MSVC, but when loading the dll in a wish, the
> wish performed an illegal operation and was shut down.
> Anything else I could try ? (using the borland compiler ?? what command
> lines ??)

I think this might be a known (and unrelated) bug.  :^)

Donal.
--

-- [Perl] is mostly pretty "intuitive" in a certain way.



Tue, 22 Jul 2003 19:11:23 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Tcl8.1b1 regexp's are now 17 times slower than in Tcl8.0.4

2. tcl80.dll for tcl8.0.3 doesn't contain underscore identifiers

3. behaves differently in Tcl8.5 than in Tcl8.4

4. Tcl8.0 vs. Tcl8.4 in WinXP

5. ANN: tcl8.4.2++.pdf, tcl8.4.2++.chm

6. Tnm 3.0.0 and tcl8.3 and tcl8.4

7. BUG: Tcl_AppendResult broken in tcl8.3.4 and tcl8.4

8. Difference between tcl8.0 and tcl8.3 entry widget

9. BUG in tcl8.0.5 and tcl8.1 with variable scope

10. regexp in Tcl8.1 is 7 times slower then Tcl8.0 in this simple example

11. Tcl8.0p2, Tcl8.1a1: BUG+PATCH: lsort -dictionary compares signed chars

12. Tcl8.4.0, load and LD_LIBRARY_PATH

 

 
Powered by phpBB® Forum Software