c++ - How to tell TCL and TK that default `.tcl` language files should be searched locally? -


when compile tcl/tk manually sources or install activestate following structure in tcl/tk installation folder:

  +- bin        +- tcl85.dll        +- tk85.dll   //...   +- lib/        +- tcl8.5/             //all tcl files (.tcl)        +- tk8.5/             //all tk files (.tcl)   //... 

so when compile app of yours , link tcl , tk dll's dll's search tcl/tk files in relative tham (to dll's) directory ../lib/tk8.5 , ../lib/tcl8.5. makes quite hard distribute app not having make end users install tcl , tk.

i want distribute c++ app.

i use cpptk default gui layout.

i want make possible end users not have need in installing tcl , tk. want provide them folders tk , tcl .tcl source files located in directory relative app extras/tcl , extras/tk. how tell tk , tcl dlls source file folders are? tk , tcl api function names doing that? there special cpptk functions that?

update tried donal fellows answer next folder structure.

app/   +- app.exe   +- tcl85.dll   +- tk85.dll   +- extras/        +- tcl/             //all tcl files can find in tcl install folder/ lib/tcl8.5        +- tk/             //all tk files can find in tcl install folder/ lib/tk8.5 

my code looked like:

#include <stdio.h> #include "cpptk/cpptk.h" using namespace tk; int main(int, char *argv[]) { static char* str = "set extrasdir [file dirname [info nameofexecutable]]/extras\n" "# use load code...\n" "source $extrasdir/tcl/init.tcl\n" "# way load code, using *.tk files directory:\n" "foreach tkfile [glob -nocomplain -directory $extrasdir/tk *.tk] {\n" "    source $tkfile\n" "}\n"; // next part in function or method... //std::string script("the script evaluate goes here"); std::string result = tk::details::expr(str,true); // think correct std::cout<< result << std::endl; std::cin.get(); tk::init(argv[0]); button(".b") -text("say hello"); pack(".b") -padx(20) -pady(6); tk::runeventloop(); std::cin.get(); } 

it compiles failes on line 36 of cpptkbase.cc

btw: used this html\js app char string.

if have directory contains binary, , want locate tcl files relative it, this:

 yourapp1.0/   +- yourapp.exe   +- extras/        +- tcl/             +- foo.tcl             +- bar.tcl        +- tk/             +- grill.tk 

then can write tcl code find scripts. code this:

set extrasdir [file dirname [info nameofexecutable]]/extras # use load code... source $extrasdir/tcl/foo.tcl source $extrasdir/tcl/bar.tcl # way load code, using *.tk files directory: foreach tkfile [glob -nocomplain -directory $extrasdir/tk *.tk] {     source $tkfile } 

if you're using script main program, otherwise set in structure above, you'd use $argv0 (a special global variable) instead of [info nameofexecutable]. or possibly [info script] (though there caveats that).


[edit]: make code work c++/tk, need trickier. in particular, need access guts:

#include "cpptk.h" // might need "base/cpptkbase.h" instead #include <string>  // next part in function or method... std::string script("the script evaluate goes here"); std::string result = tk::details::expr(script,true); // think correct 

i should warn don't write c++ there's fair chance won't work; it's based off reading c++/tk source , taking guess. caveat emptor.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -