Am 29.07.18 um 21:44 schrieb Adam Jensen:
> On Sun, 29 Jul 2018 20:11:06 +0200, Christian Gollwitzer wrote:
>
>> Am 28.07.2018 um 06:59 schrieb Adam Jensen:
>>
>>> Get "tclmpv.c" from <
https://wiki.tcl-lang.org/55174>
>>>
>>> On Ubuntu 18.04, I had to change line 11 From: #include <tcl.h>
>>> To: #include <tcl/tcl.h>
>>>
>>> Compile:
>>>
>>> gcc -c -fpic tclmpv.c -ltclstub -lmpv
>>
>> I think this line is missing a "-DUSE_TCL_STUBS". It works by chance if
>> you leave it out (on Linux only), and you will end up with undefined
>> symbols in the .so, but it will not work as intended for stubs. i.e. you
>> can load the resulting .so into a different version of Tcl only if
>> compile with -DUSE_TCL_STUBS and link with -ltclstub. Oh, and for the
>> compile line, you can drop the -l libraries, they have no effect. OTOH
>> you could add -I/usr/include/tcl (or similar) so you don't need to patch
>> the #include line.
>>
>>> gcc -shared -o tclmpv.so tclmpv.o -ltclstub -lmpv
>>
>> Christian
>
> Nice. Thanks!
>
> Does the compile command need "-DUSE_TCL_STUBS" even though the source
> file specifies "#define USE_TCL_STUBS"?
Ah, sorry - I haven't checked this. The -D switch at the command line
and the #define are doing the same thing. For some (mostly historical)
reasons, it is usually not #defined in the sources, but here you are
right. The warning rightly tells you that the stubs are already enabled.
> So for a multi-platform extension, what is the best practice? On my
> Ubuntu machine, either the source can specify "#define USE_TCL_STUBS" or
> the compile command can specify "-DUSE_TCL_STUBS" and the build will be
> smooth, or USE_TCL_STUBS can be specified in both the source file and the
> compile command and that will result in a warning but still produces a
> seemingly functioning ".so" extension.
The only real problem comes up when you don't define "USE_TCL_STUBS" and
link to
libtcl8.6.so (which makes the extension loadable only into the
exact same version of Tcl), or worse, link to libtclstub8.6.a (which
creates an invalid file).
For multiplatform, the "correct" way is to package it up with tclconfig,
then you get an autoconf package which detects Tcl for you, lets you do
./configure && make install etc. Look here if you want to do this:
https://wiki.tcl-lang.org/5464
Since this is mostly mechanical work and Brad said that the extension
was not finished, he was probably just too lazy to do this.
Christian