It's my first time trying to port a C project to TCL.
I'm having difficulties with some "undefined symbol" error when loading
the library to tclsh.
---
$ make
gcc ./src/raylib/unity.c ./vendor/raylib/src/libraylib.a -shared -o liblst_raylib.so -DUSE_TCL_STUBS -ltclstub8.6 -ggdb -Wall -Werror -fsanitize=address -fPIC
echo "TODO : load liblst_raylib.so"
TODO : load liblst_raylib.so
# preloading libasan.so librairy for address sanitazation LD_PRELOAD=/usr/lib64/gcc/x86_64-solus-linux/15/../../../../lib64/libasan.so tclsh
% load ./liblst_raylib.so
cannot find symbol "Lst_raylib_Init": /home/frizzus/Documents/code/Lime-Stained-Terracota/liblst_raylib.so: undefined symbol: _Lst_raylib_Init
%
---
I've tried looking for "_Lst_raylib_Init" in my whole project.
I even tried greping through the C code after preprocessing ( with gcc
-E command ).
This symbol is not even called once in the entirety of the source code.
Did this kind of error append to one of you ?
The C project github : https://github.com/nicbarker/clay
My code repo : https://codeberg.org/Frizzus/Lime-Stained-Terracota
* Frizzus <loic.canin@murena.io>Yes, and it is important that the name match the library name. It is possible to override that with a second argument to the load command, but this is discurraged.
| % load ./liblst_raylib.so
| cannot find symbol "Lst_raylib_Init":
| /home/frizzus/Documents/code/Lime-Stained-Terracota/liblst_raylib.so:
| undefined symbol: _Lst_raylib_Init
As Robert pointed out, you need to provide that function in your
extension module. See
https://wiki.tcl-lang.org/page/Hello+World+as+a+C+extension
for an example. You need to adjust the Hello_Init() function to your library.
R'
At Thu, 16 Oct 2025 16:00:39 +0200 Ralf Fassel <ralfixx@gmx.de> wrote:
* Frizzus <loic.canin@murena.io>
| % load ./liblst_raylib.so
| cannot find symbol "Lst_raylib_Init":
| /home/frizzus/Documents/code/Lime-Stained-Terracota/liblst_raylib.so:
| undefined symbol: _Lst_raylib_Init
As Robert pointed out, you need to provide that function in your
extension module. See
https://wiki.tcl-lang.org/page/Hello+World+as+a+C+extension
for an example. You need to adjust the Hello_Init() function to your
library.
Yes, and it is important that the name match the library name. It is possible
to override that with a second argument to the load command, but this is discurraged.
R'
Is this a common pattern in dynamic library to have the entry function matching the library name ?
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,075 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 114:04:02 |
| Calls: | 13,799 |
| Calls today: | 1 |
| Files: | 186,990 |
| D/L today: |
5,510 files (1,588M bytes) |
| Messages: | 2,439,079 |