Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2013-09-06
23:09 • Ticket [8419b6d9ae] Dynamic linking requres unicode on windows status still ... artifact: b5bd32378f user: jan.nijtmans
22:53 • Closed ticket [8419b6d9ae]. artifact: 84ebaeac72 user: jan.nijtmans
22:49 • Add attachment if_tcl.c.diff to ticket [8419b6d9ae] artifact: 8dbf6cf24a user: jan.nijtmans
2013-09-04
09:56 • Ticket [8419b6d9ae] Dynamic linking requres unicode on windows status still ... artifact: bbdc4bd7cd user: anonymous
2013-09-03
22:07 • Ticket [8419b6d9ae]: 3 changes artifact: f7ea773973 user: anonymous
21:53 • Ticket [8419b6d9ae]: 3 changes artifact: 961dd4c2c3 user: anonymous
12:40 • Ticket [8419b6d9ae]: 3 changes artifact: a469faf727 user: dgp
2013-09-02
13:35 • Ticket [8419b6d9ae]: 3 changes artifact: c5377e696b user: jan.nijtmans
13:12 • Pending ticket [8419b6d9ae]. artifact: f71b7e9513 user: jan.nijtmans
2013-09-01
22:07 • Ticket [8419b6d9ae]: 3 changes artifact: 3fc082765b user: jan.nijtmans
2013-08-30
20:37 • Ticket [8419b6d9ae]: 3 changes artifact: f099cd7ea6 user: anonymous
17:15 • Ticket [8419b6d9ae]: 6 changes artifact: d4f3bca714 user: dgp
2013-08-29
16:34 • New ticket [8419b6d9ae]. artifact: 13ff484bc9 user: anonymous

Dynamic linking requres unicode on windows

Closed / Works For Me8419b6d9ae1cfc61a215d4cd588304df2981b76fCreated 13 years agoUpdated 13 years ago
Descriptionplain2013-08-29 16:34:14
For windows, tclDecls.h undefines tcl_FindExecutable and redefines it only if UNICODE is defined.   Therefore dynamic linking fails on non-UNICODE apps because of the undefined call.

I was attempting to compile VIM7.4 with tcl dynamically linked, but it failed.  I successfully compiled it by statically linking tcl.  

Windows 7, 64 bit, mingw64 compiler using source code from master branch of tcl repo.
dgpplain2013-08-30 17:15:13
Passing on to nijtmans, who I think is behind the changes.

If the OP reads this, please clarify what release of Tcl
(or checkin snapshot) you are trying to build.
anonymousplain2013-08-30 20:37:28
Regarding request for which snapshot:   Here is the info from fossil: 

project-code: 1ec9da4c469c29f4717e2a967fe6b916d9c8c06e
checkout:     608930382ff3d2acdfdefa87a99ddb01ac63495b 2013-08-24 09:42:43 UTC
parent:       af7ffdb548b4a5e6cf7049119c08571bf3c851fb 2013-08-23 16:23:47 UTC
merged-into:  219c73f7e8373b7c25c0af595b92e899fca1eb8e 2013-08-26 18:32:55 UTC
tags:         trunk
comment:      Unbreak doc; the apropos index entry *must* be one line. (This
              is an external constraint forced by the requirement to fit into
              the standard Unix manual system.) (user: dkf)
checkins:     16451

I'm not very familiar with fossil usage. So post again if more info is needed.
jan.nijtmanswiki2013-09-01 22:07:12

What's the error-message when linking? Is it a missing tclStubsPtr symbol? If so, then the problem is that you compiled your application with -DUSE_TCL_STUBS, but the tclStubPtr symbol was removed from the shared library. It works when statically linking, probably because you linked with the stub library which has this symbol.

This has no relation with -DUNICODE, for Unicode applications this wouldn't work either.

Solution: compile your application without -DUSE_TCL_STUBS.

>Passing on to nijtmans, who I think is behind the changes.

No I'm not in this case..... It's the removal of tclStubsPtr from the shared library which causes this change compared to 8.5

jan.nijtmanswiki2013-09-02 13:12:15

Let's take a minimal example:

#include <tcl.h>
void main(int argc, const char *argv[]){
  Tcl_FindExecutable(argv[0]);
  printf("OK\n");
}

Then (from a Cygwin or MSys shell):

$ i686-w64-mingw32-gcc -o main.exe main.c -I/Tcl/include -DUNICODE -D_UNICODE -L/Tcl/lib -ltcl86
$ ./main.exe
OK
$ i686-w64-mingw32-gcc -o main.exe main.c -I/Tcl/include -L/Tcl/lib -ltcl86
$ ./main.exe
OK

Using -DUSE_TCL_STUBS has exactly the same result, for Tcl_FindExecutable that doesn't make any difference (for other functions it does)

Sorry, I cannot reproduce this problem.

jan.nijtmans Ticket [8419b6d9ae]: 3 changes [History diff]2013-09-02 13:35:11
dgpplain2013-09-03 12:40:58
Thank you nijtmans for the demonstrations.

One detail I notice is that the ticket was opened
complaining about building with mingw64 and your
demos appear to be with mingw32 (or I just don't
know how to decode the names).  Any chance that
could matter?
anonymousplain2013-09-03 21:53:06
When compiling/linking, the only error I received was:
objx86-64/if_tcl.o:if_tcl.c:(.text+0x2edd): undefined reference to `Tcl_FindExecutable'

The relevant part of the compile was: 
-Id:/tools/tcl/include -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl
86.dll\" -DUSE_TCL_STUBS ...   -Ld:/tools/tcl/lib -ltclstub86

In tclDecls.h, this function is undefined on WIN32 when UNICODE is not defined. 

In your example, you did not link to tclstub86, but to the tcl86, which I understood to be the static lib.
anonymousplain2013-09-03 22:07:25
Just another note: 

I did some more research and checked here: 
http://tcl.activestate.com/doc/howto/stubs.html

Perhaps a better description of this bug is "Dynamic Linking thru tclStubs requires UNICODE on windows"

With the way tclDecls.h is defined, you cannot use stubs on Windows unless UNICODE is defined.
anonymousplain2013-09-04 09:56:48
After compiling the example program given earlier by jan, I see that UNICODE is not the problem.  I apologize.

The problem is compiling against the tclstub lib. I have yet to build an example that complies and not crash.    But that is probably on my end.
jan.nijtmansplain2013-09-06 22:53:12
I see the problem. Attached to this ticket is a patch for if_tcl.c how this should be solved.

The problem is that Tcl_FindExecutable() should be called BEFORE Tcl_CreateInterp(), which cannot be done through the stub table
because it is not initialized yet. See the attached patch for
the proper way how to do this. Tcl_FindExecutable() is in
the stub table, but that was a design mistake. In Tcl 8.6
that cannot be done any more, that's on purpose.

I hope this helps you further.
jan.nijtmanswiki2013-09-06 23:09:59

Reported to the VIM people as well:

https://code.google.com/p/vim/issues/detail?id=167

Log in (anonymous is fine) to add a comment.

Attachments: