Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
TCL & C linker problem

Posted by acidburn123 (acidburn123), 27 April 2008
Hey 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:

Flag:
./gcc test1.c -ltk -ltcl -lm

Error
/usr/bin/ld: cannot find -ltk
collect2: ld returned 1 exit status

Posted by admin (Graham Ellis), 27 April 2008
Looks 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 2008
I 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 2008
There 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 2008
Hey thanks for your help so far Graham. I've done a locate libtk and got the following results

/usr/lib/libtk8.4.so.0
/usr/lib/libtkstub8.4.a
/usr/lib/libtk8.4.a
/usr/lib/libtk8.4.so.1
/usr/lib/libtk8.4.so

Daft question how do I get gcc to compile these files?

Posted by admin (Graham Ellis), 28 April 2008
Technically, 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 2008
Thank you, it all works now



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho