[comp.sys.mac] LSC and Printf

chw@prism.TMC.COM (03/08/88)

      I ran into this too when first setting up Lightspeed C and the 
manual didn't help much.  What you have to do is add libraries
to your "project".  There is a menu command for doing this and the 
manual shows how to do it, but it doesn't tell which libraries you
need to add.  For your test program, you would need to add the stdio 
and mac libraries.

	----
	Christopher H. Wilbur   chw@mirror.TMC.COM
		       {mit-eddie, ihnp4, wjh12, cca, cbosgd, seismo}!mirror!chw
	Mirror Systems	2067 Massachusetts Avenue  Cambridge, MA  02140
	Telephone:	617-661-0777			

long@colors.dec.com (LOCAL NODE: *INSERT COMMERCIAL HERE*) (03/09/88)

>    I guess I am missing something in LightSpeed C. The following program
>compiles, but dies on link...... I guess I'm alittle green:
> 
>        #include "stdio.h"
>        main()
>        {
>           int i;
> 
>           i = 1;
>           while( i<=5 ) {
>              printf("%d\n",i);   /* can't find printf at link */
>              i= i + 1;
>           }
>        }
 
well...  there's a couple of things to try.  first, the #include line
should read :

#include <stdio.h>

it makes a difference as to where the compiler looks for the file.

as to the link error, you must include the "stdio" library in your project.
check the manual for more specifics.

good luck, rich

leonardr@uxe.cso.uiuc.edu (03/09/88)

gonter@leadsv.UUCP(C. Gonter) writes in comp.sys.mac

>    I guess I am missing something in LightSpeed C. The following program
>compiles, but dies on link...... I guess I'm alittle green:
>
>	#include "stdio.h"
>	main()
>	{
>	   int i;
>
>	   i = 1;
>	   while( i<=5 ) {
>	      printf("%d\n",i);   /* can't find printf at link */
>	      i= i + 1;
>	   }
>	}
	With Lightspeed C not only do you have to do use the #include stdio.h
but you also have to include in your project the stdio library.  The library
is where all the support for non-Maclike I/O is handled.  


+---------------------------------+-----------------------------------+
+                                 +  Any thing I say may be taken as  +
+   Leonard Rosenthol             +  fact, then again you might decide+
+   President, LazerWare, inc.    +  that it really isn't, so you     +
+                                 +  never know, do you??             +
+   leonardr@uxe.cso.uiuc.edu     +                                   +
+   GEnie:  MACgician             +                                   +
+   Delphi: MACgician             +                                   +
+                                 +                                   +
+---------------------------------+-----------------------------------+

rs4u+@andrew.cmu.edu (Richard Siegel) (03/13/88)

The solution is to be sure that the "stdio" library file is added to your
project.

A complete walkthrough of creating the "hello world" program can be 
found on page 47 of the LightspeedC 2.01 Release Supplement.

	-Rich