title: Embedding Tcl in a C program
body: <p>I am trying to create a simple c++ console app that calls the nagelfar syntax checker on a script. I followed the directions here: <a href="http://wiki.tcl.tk/19919" rel="nofollow">http://wiki.tcl.tk/19919</a> , adding the <code>tclstub85.lib</code> to my input, adding the tcl lib directory to my additional libraries, and adding my header directory as well. Linking fails with: </p>
  
  <pre><code>main.obj : error LNK2001: unresolved external symbol _tclStubsPtr 
  </code></pre>
  
  <p>This is my command line for linking: </p>
  
  <pre><code>/OUT:"C:\Users\######\Documents\Visual Studio 2005\Projects\Nagelfar\Release\Nagelfar.exe"
  /NOLOGO /LIBPATH:"C:\Tcl\lib" /MANIFEST 
  /MANIFESTFILE:"Release\Nagelfar.exe.intermediate.manifest" /DEBUG
  /PDB:"c:\users\######\documents\visual studio 2005\projects\nagelfar\release\Nagelfar.pdb"
  /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT C:\Tcl\lib\tclstub85.lib
  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
  shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib 
  </code></pre>
  
  <p>This is the full source code, which I can compile and run fine in Linux using g++:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;tcl.h&gt;
  #include &lt;string.h&gt;
  
  Tcl_Interp * tcl_interp ;
  char fileToCheck[] = "test.tcl";
  char dbFile[] = "syntaxdb.tcl";
  
  int main () {
      int code, argc;
      const char **argv;
      char command[1024];
      char *results = NULL; 
      tcl_interp = Tcl_CreateInterp();
      Tcl_SetVar2(tcl_interp, "::Nagelfar", "embedded", "1", 0);  
      code = Tcl_EvalFile(tcl_interp, "nagelfar.tcl"); 
      Tcl_LinkVar(tcl_interp, "::Nagelfar(chkResult)", (char *)&amp;results, TCL_LINK_STRING); 
      sprintf(command, "synCheck %s %s", fileToCheck, dbFile); 
      code = Tcl_Eval(tcl_interp, command);
      printf("Raw Result: \r\n %s\r\n", results); 
      code = Tcl_SplitList(tcl_interp, results, &amp;argc, &amp;argv); 
      {
          int i;
          for (i = 0; i &lt; argc; ++i)
          {
              printf("%d/%d: %s\r\n", i+1, argc, argv[i]); 
          }
      }
      Tcl_Free(results);
      return 0;
  }
  </code></pre>
  
  <p>Solved my own problem: I had x64 ActiveTcl but was linking a 32 bit project. Using the x86 ActiveTcl distribution fixed my issues.</p>