TCL & C linker problem
Posted by acidburn123 (acidburn123), 27 April 2008Hey there,
First off I'd like to say Hello you, I'm new
Secondly I've searched this forum for TCL and C linker problems and have noticed a few have come up, but never understood the solution hence the 'prepost'
I've got some C code and TCL code, but when I compile the C code with the following flags I get this error:
./gcc test1.c -ltk -ltcl -lm
/usr/bin/ld: cannot find -ltk
collect2: ld returned 1 exit status
Posted by admin (Graham Ellis), 27 April 2008Looks like you may not have the Tk (and Tcl?) libraries installed on your system or in a library directory that gcc looks at. You'll be looking for a file called libtk.so (or something like that) and if it's in a directory that's not on the Library path, you can add that to your gcc using a -L option.
Posted by acidburn123 (acidburn123), 27 April 2008I did the locate command and it returned nothing. However if i type wish the GUI works. Would this not imply that I've got TK \ TCL installed?
Posted by admin (Graham Ellis), 28 April 2008There may be a .0 or .a or something on the end of it - as I said the name is something like and it depends on how it was installed / compiled. Look for anything starting with "libtk" not just the exact name I gave you. And ... do you have Tcl and Tk installed on the machine at all? I'm not clear on that; if so, good, if not - then install it and test it before you bring C in as well!
Posted by acidburn123 (acidburn123), 28 April 2008Hey thanks for your help so far Graham. I've done a locate libtk and got the following results
Daft question how do I get gcc to compile these files?
Posted by admin (Graham Ellis), 28 April 2008Technically, the libraries are already compiled so you do not need gcc to compile them - you just need to load them. Gcc (inspite of its name) runs a series of steps including the C preprocessor (cpp) the compiler and assember stages (I forget what they're called) and the loader (ld).
In order to get gcc to include a library in its load phase, the -l option is the one to use ... -ltk84. should do in your case. If the libraries were elsewhere (not in the usual library path), a -L option or setting an environmanet variable could be needed, but I don't think you'll need that.
Posted by acidburn123 (acidburn123), 29 April 2008Thank you, it all works now
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho