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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: 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