1
votes

I am very new to tcl.

I am trying to load a dll using the load command but I get an undefined symbol error.

I am pretty sure the message is implying that the dll is for a specific (proprietary) interpreter.

If I try to do the load from "wish" I get the error, but If I do the load from the proprietary interpreter it loads fine.

I see that on the load command I can pass in a packageName and interp. I am thinking that if I pass in the proprietary interpreter, I may be able to get this to work, but if I pass in the path to the interpreter I get an error message saying it can't fine the interpreter. Does anyone know what interp= is expecting?

BTW, I can't just used the proprietary interpreter because I am really just trying to call tcl commands from ruby, and I don't have the headers to compile ruby with that interpreter.

the commands, I get an error message saying there is and undefined symbol.

1

1 Answers

2
votes

The load command does two things:

  1. It locates the specified shared library and makes it “present” in the process. (The OS API used for this varies; on Unix it's usually dlopen(), and on Windows it is LoadLibraryEx().)

  2. It then locates the initialisation function within the library and calls it, passing in a handle to the interpreter that is to gain functionality from the library. The initialisation function has a name that is typically derived from the name of the library; if you were loading foobar72.dll, then the function would be called Foobar_Init. Tcl always assumes that the type signature of the initialisation function is this:

    int InitFunc(Tcl_Interp *interp);
    

I'm guessing that the first stage worked but the second stage failed; there's no initialisation function present, and the library isn't designed to work with Tcl. (In particular, it also wouldn't know how to use Tcl's API to register commands, set up variables, etc.)

The ways to fix this are:

  1. Use a tool like SWIG to create a wrapper library.
  2. Use a Tcl extension like ffidl to do direct API calls.
  3. Use a Tcl extension like critcl to write a wrapper library in Tcl.
  4. Write the wrapper by hand. (This isn't very hard IMO, but YMMV.)

You should be aware that C APIs surfaced by SWIG and ffidl feel very strange in Tcl normally; you usually have to write further Tcl code around them to make the interface natural. (This isn't a criticism of those APIs; just acknowledgement that the C and Tcl languages have different notions of what “natural” means.)

To say what the best way forward for you is, we'd need quite a lot more information. You're probably better expressing that as a separate question.