From: Alan Grunwald on
I've decided that I'd be best off writing some code that I need in C
and provide it as a package.

So, I found wiki.tcl.tk/11153 - Hello World as a C extension. I've
built hello.so, but

% load ./libhello.so

fails with

couldn't load file "./libhello.so": ./libhello.so: undefined symbol:
tclStubsPtr

I'm using Tcl 8.6b1.2, on Ubuntu Linux, installed in
/opt/ActiveTcl-8.6. I built libhello.so with the command

$ gcc -shared -o libhello.so -DUSE_TCL_STUBS
-I/opt/ActiveTcl-8.6/include/tcl8.6 hello.c -Ltclstub8.6

Can someone provide a pointer to what I'm doing wrong?

Many thanks,
--
Alan
From: Aric Bills on
On Jul 25, 11:10 am, Alan Grunwald <alan-clt-
pos...(a)nospam.demon.co.uk> wrote:
>         I've decided that I'd be best off writing some code that I need in C
> and provide it as a package.
>
>         So, I found wiki.tcl.tk/11153 - Hello World as a C extension. I've
> built hello.so, but
>
>         % load ./libhello.so
>
> fails with
>
>         couldn't load file "./libhello.so": ./libhello.so: undefined symbol:
> tclStubsPtr
>
>         I'm using Tcl 8.6b1.2, on Ubuntu Linux, installed in
> /opt/ActiveTcl-8.6. I built libhello.so with the command
>
>         $ gcc -shared -o libhello.so -DUSE_TCL_STUBS
> -I/opt/ActiveTcl-8.6/include/tcl8.6 hello.c -Ltclstub8.6
>
>         Can someone provide a pointer to what I'm doing wrong?
>
> Many thanks,
> --
> Alan

I believe the call to gcc should go like this:

gcc -shared -o libhello.so -DUSE_TCL_STUBS \
-I/opt/ActiveTcl-8.6/include hello.c \
-L/opt/ActiveTcl-8.6/lib -ltclstub8.6
From: hae on
On 25 Jul., 19:10, Alan Grunwald <alan-clt-pos...(a)nospam.demon.co.uk>
wrote:
>         I've decided that I'd be best off writing some code that I need in C
> and provide it as a package.
>
>         So, I found wiki.tcl.tk/11153 - Hello World as a C extension. I've
> built hello.so, but
>
>         % load ./libhello.so
>
> fails with
>
>         couldn't load file "./libhello.so": ./libhello.so: undefined symbol:
> tclStubsPtr
>
>         I'm using Tcl 8.6b1.2, on Ubuntu Linux, installed in
> /opt/ActiveTcl-8.6. I built libhello.so with the command
>
>         $ gcc -shared -o libhello.so -DUSE_TCL_STUBS
> -I/opt/ActiveTcl-8.6/include/tcl8.6 hello.c -Ltclstub8.6
>
>         Can someone provide a pointer to what I'm doing wrong?
>
> Many thanks,
> --
> Alan

Hello Alan,

there is a sample extension that uses the standard tools autoconf,
configure and make. See here http://wiki.tcl.tk/5464 and here
http://wiki.tcl.tk/14150 for information.

Rüdiger
From: Alan Grunwald on
On 26/07/10 06:27, Aric Bills wrote:
> On Jul 25, 11:10 am, Alan Grunwald<alan-clt-
> pos...(a)nospam.demon.co.uk> wrote:
>> I've decided that I'd be best off writing some code that I need in C
>> and provide it as a package.
>>
>> So, I found wiki.tcl.tk/11153 - Hello World as a C extension. I've
>> built hello.so, but
>>
>> % load ./libhello.so
>>
>> fails with
>>
>> couldn't load file "./libhello.so": ./libhello.so: undefined symbol:
>> tclStubsPtr
>>
>> I'm using Tcl 8.6b1.2, on Ubuntu Linux, installed in
>> /opt/ActiveTcl-8.6. I built libhello.so with the command
>>
>> $ gcc -shared -o libhello.so -DUSE_TCL_STUBS
>> -I/opt/ActiveTcl-8.6/include/tcl8.6 hello.c -Ltclstub8.6
>>
>> Can someone provide a pointer to what I'm doing wrong?
>>
>> Many thanks,
>> --
>> Alan
>
> I believe the call to gcc should go like this:
>
> gcc -shared -o libhello.so -DUSE_TCL_STUBS \
> -I/opt/ActiveTcl-8.6/include hello.c \
> -L/opt/ActiveTcl-8.6/lib -ltclstub8.6

Many, many thanks Aric. That should indeed be the command line. I don't
know how many times I compared what I'd written with what is on the wiki
without spotting it. I guess I should have set up TCLINC and TCLLIB
environment variables and used exactly what was on the wiki.

Anyway, it's working now, thanks again.

PS I guess this will be only the first of a number of embarrassing
newbie questions. :-(
--
Alan
From: Larry W. Virden on
On Jul 26, 5:17 am, Alan Grunwald <alan-clt-pos...(a)nospam.demon.co.uk>
wrote:

>
> PS I guess this will be only the first of a number of embarrassing
> newbie questions. :-(

While embarassing, please don't let the embarassment prevent you from
asking after you've tried to find the answers. It is better to ask and
get an answer than to give up because you couldn't find the answer.