Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compile DLL for Tcl with Visual Studio 2017

170 views
Skip to first unread message

in...@meshparts.de

unread,
Jul 26, 2017, 10:34:05 AM7/26/17
to
Hi,

I'm trying to compile a DLL for Tcl using Visual Studio 2017.
I get these message errors:

Error LNK2019 Reference to unresolved external symbol "Tcl_InitStubs" in function "Meshparts_Init".
Error LNK2001 Unresolved external symbol "tclStubsPtr".

I'm using these user defined command line options:

-shared -DUSE_TCL_STUBS -IC:/Tcl/include -LC:/Tcl/lib -ltclstub86 -O3 -march=native

Any ideas how to solve this?

Many thanks
Alexandru

Robert Heller

unread,
Jul 26, 2017, 10:57:00 AM7/26/17
to
My *guess* is that the libtclstub86.lib file in C:/Tcl/lib was not built with
Visual Studio 2017 (or a compatible version of Visual Studio). I would
*guess* that a lib file built with mingw32 (eg gcc), won't work with Visual
Studio and Visual Studio might have version fussiness.

>
> Many thanks
> Alexandru
>
>

--
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services

in...@meshparts.de

unread,
Jul 26, 2017, 12:14:06 PM7/26/17
to
Am Mittwoch, 26. Juli 2017 16:57:00 UTC+2 schrieb Robert Heller:
I think you are wright!
I compiled my Tcl with Paul Obermeier's BAWT. I don't now yet what compiler BAWT uses (or perhaps it's a configuration option) but I'll check that.

Many thanks for the hint!

Regards
Alexandru

Christian Gollwitzer

unread,
Jul 26, 2017, 1:38:11 PM7/26/17
to
Am 26.07.17 um 18:14 schrieb in...@meshparts.de:
> Am Mittwoch, 26. Juli 2017 16:57:00 UTC+2 schrieb Robert Heller:
>>> Error LNK2019 Reference to unresolved external symbol "Tcl_InitStubs" in function "Meshparts_Init".
>>> Error LNK2001 Unresolved external symbol "tclStubsPtr".
>>>
>>> I'm using these user defined command line options:
>>>
>>> -shared -DUSE_TCL_STUBS -IC:/Tcl/include -LC:/Tcl/lib -ltclstub86 -O3 -march=native

-march=native is a gcc switch (to optimize for the CPU where gcc is
currently running). You should get a warning or error from VC++ as well.
I think the analogous VC switch would be /arch:AVX or a similar switch.
If you do not see a warning about an unsupported switch, please check if
your options arrive at the compiler at all. Also, -shared is suspicious,
usually it is /LD


>>> Any ideas how to solve this?
>>

> I think you are wright!
> I compiled my Tcl with Paul Obermeier's BAWT. I don't now yet what compiler BAWT uses (or perhaps it's a configuration option) but I'll check that.

BAWT always compiles using gcc. The good news is, that because of the
Tcl stub mechanism, you can actually load extensions compiled using a
different compiler. I'd install ActiveTcl and try to link against the
tclsub86.lib which they provide.

Christian

Paul Obermeier

unread,
Jul 26, 2017, 2:12:50 PM7/26/17
to
Am 26.07.2017 um 19:38 schrieb Christian Gollwitzer:
> Am 26.07.17 um 18:14 schrieb in...@meshparts.de:
>> Am Mittwoch, 26. Juli 2017 16:57:00 UTC+2 schrieb Robert Heller:
>>>> Error LNK2019 Reference to unresolved external symbol
>>>> "Tcl_InitStubs" in function "Meshparts_Init".
>>>> Error LNK2001 Unresolved external symbol "tclStubsPtr".
>>>>
>>>> I'm using these user defined command line options:
>>>>
>>>> -shared -DUSE_TCL_STUBS -IC:/Tcl/include -LC:/Tcl/lib -ltclstub86
>>>> -O3 -march=native
>
> -march=native is a gcc switch (to optimize for the CPU where gcc is
> currently running). You should get a warning or error from VC++ as well.
> I think the analogous VC switch would be /arch:AVX or a similar switch.
> If you do not see a warning about an unsupported switch, please check if
> your options arrive at the compiler at all. Also, -shared is suspicious,
> usually it is /LD
>
I also suspect, you are mixing gcc and VS commands.
>
>>>> Any ideas how to solve this?
>>>
>
>> I think you are wright!
>> I compiled my Tcl with Paul Obermeier's BAWT. I don't now yet what
>> compiler BAWT uses (or perhaps it's a configuration option) but I'll
>> check that.
>
> BAWT always compiles using gcc. The good news is, that because of the
> Tcl stub mechanism, you can actually load extensions compiled using a
> different compiler. I'd install ActiveTcl and try to link against the
> tclsub86.lib which they provide.
>
Not completely true. As stated on the BAWT download site:
Green marked packages are Tcl related and contained in file Setup/Tcl.bawt.
These libraries are compiled with MSys/MinGW on Windows, with the
exception of TclStubs, TkStubs, tkdnd, Mpexpr, which need Visual Studio
for compilation.

So, to generate the stubs libraries for Tcl and Tk you need a
VisualStudio version. VS 2017 is not yet supported, but should be easily
possible.
Just specify "vs2017" when starting BAWT and add appropriate lines in
file Build.bawt, if you get an error message like this:
Unsupported compiler version "vs2017"

Paul
0 new messages