我一直在關注使用Swig將C和TCL結合在一起的教程。該教程似乎正常工作,但最終我遇到了一個我無法解決的錯誤。情況如下:使用Swig結合使用C和TCL
我跟着的教程是: http://www.swig.org/tutorial.html。
我有一個名爲test.c的文件:
char *HelloWorld()
{
return "hello world";
}
,另一個名爲test.i:
%module test
%{
/* Put header files here or function declarations like below */
extern char *HelloWorld();
%}
extern char *HelloWorld();
然後我用下面的命令行參數來準備正確的文件:
gcc -c test.c -o test.o
swig -tcl test.i
gcc -c test_wrap.c -o test_wrap.o
gcc -dynamiclib -framework Tcl test.o test_wrap.o -o test.so
最後我試着加載它:
tclsh
% load test.so test
這是我收到以下錯誤點:
dlsym(0x100600090, Test_Unload): symbol not founddlsym(0x100600090, Test_SafeUnload): symbol not found
據我所知,我沒有從教程流浪。任何人都可以告訴我這是如何得到這個錯誤,更重要的是如何擺脫它?
在此先感謝!
Tcl有它自己的*優秀的* C接口。我建議只研究它,而不是浪費時間在SWIG上。 – kostix
我會,但我做這個教程的原因是,我可以稍後在我的TCL腳本中使用已提供的SWIG接口和C文件。我擔心它不會在TCL中使用C代碼的其他方式。 – Tom
做'文件test.so'和'nm -AC test.so'並顯示輸出 – vrdhn