From lvirden@cas.org Fri Apr 24 05:59:55 CDT 1998 Article: 83637 of comp.lang.tcl Path: uuneo.neosoft.com!ultraneo.neosoft.com!dca1-hub1.news.digex.net!digex!news.idt.net!newsfeed.internetmci.com!192.232.20.2!malgudi.oar.net!news.cas.org!not-for-mail From: lvirden@cas.org Newsgroups: comp.lang.tcl Subject: Re: Problem in compilation Date: 20 Apr 1998 12:28:20 GMT Organization: Nedriv Software and Shoe Shiners, Uninc. Lines: 67 Message-ID: <6hff14$ba2$1@srv38s4u.cas.org> References: <353B02B3.C4C3854A@met.fr> Reply-To: lvirden@cas.org NNTP-Posting-Host: lwv26awm.cas.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Newsreader: trn 4.0-test63 (15 March 1998) Originator: lwv26@cas.org (Larry W. Virden) Xref: uuneo.neosoft.com comp.lang.tcl:83637 According to Damien.Richard : :When I compile with this command : : : gcc -o test test.c -lX11 -lm -ldl -I/appli/aquarium/TCLTK/include/ :-L$TCL_LIBRARY : :The result is : : :Undefined first referenced : symbol in file :Tcl_EvalFile /var/tmp/cca000hM1.o :Tcl_SetVar /var/tmp/cca000hM1.o :Tcl_CreateInterp /var/tmp/cca000hM1.o :ld: fatal: Symbol referencing errors. No output written to test Virden's first rule of Unix program compilation: 1. To be on the safest ground, write your compile statement following this model: COMPLIER COMPILER_FLAGS INCLUDE_FLAGS SOURCE_CODES LINK_DIRECTORIES LINK_LIBRARIES OUTPUT_FLAGS So, in your case, the first rule would result in you writing gcc test.c -I/appli/aquarium/TCLTK/include/ -L$TCL_LIBRARY -lX11 -lm -ldl -o test However, Virden's second rule should be considered before you type return on that line: 2. Always make sure that you have listed all the include and link flags required by your application. In your case, you are missing something - flags for the tcl and tk libraries. Before correcting that, consider Virden's Corallary to the second rule of Unix program compilation: 3. Related libraries must be present in a particular order - consult your doc or FAQs for the order required. This can go beyond confusing into down right frustrating, depending on the sensibilities of the folk building the libraries. In the case of Tcl and Tk - a relatively simple rule can be used. When building a Tcl only library - just include -ltcl* (where tcl* is replaced with either tcl, or tclVersion.Level, depending on how your software is installed - look in the tcl lib*.a/lib*.so directory for the correct name). With the most current versions of Tcl and Tk, and an operating system which creates shared libraries, that's all you need to know. However, if you for some reason are not using shared libraries, then the first correlary is needed - and the rule of thumb you can use is hopefully simple to use. List the libraries in the order of most complex and dependant to least complex/dependant. That is to say, since we know that Tk needs Tcl, then to build a static Tk/Tcl application, the order of the libraries would be -ltk* -ltcl* (where the * is replaced like I mentioned in the previous paragraph). If however you are building an static X application which uses say Tix, TclX, Tk and Tcl, then you would need something like -ltix* -ltk* -ltclx* -ltcl* , since Tix needs Tk, both may need TclX, and TclX needs Tcl. -- Quote: In heaven, there is no panic, <*> O- only planning. Unless explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions.