Compile C programs in Puppy Linux 2.13

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

Compile C programs in Puppy Linux 2.13

#1 Post by Lobster »

You will need the latest 60 MB compile file eg devx_213.sfs
Download from here:

http://www.puppyos.net/test/

and place in mnt/home (this is where pup_save.2fs is)
Reboot computer

Save the following as test.c
If using Geany, set it it to C and test compile first

Code: Select all

/*  Example C program */

int main()
char input_character;

  { int i;
	   for (i = 0; i < 50000; i++)
	     {
	       printf ("%d",i);
	       printf (" Puppy is Great\n");     
	     }
	   return 0;
   }
in the same directory
open a terminal (Right click in the open folder/directory with Rox 2.5 /Window/terminal here)
and type

Code: Select all

gcc test.c -o test
this will create a runnable file called "test"
the command

Code: Select all

./test
will run it . . .

find a good tutorial eg.
http://members.cox.net/midian/articles/ansic1.htm
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#2 Post by muggins »

to show any possible errors, (as sometimes a program can compile even though it may have problems), compile with:

Code: Select all

gcc test.c -o -Wall test

User avatar
DC
Posts: 360
Joined: Sun 30 Apr 2006, 15:07
Location: Maidenhead, England

#3 Post by DC »

Hi all,
My problem,
downloaded devx_213.sfs ok.
not sure where mnt/home is so I put it in /mnt where I found some pupsave 2fs files. Rebooted and copyed the test program into new file saved as test.c
tested in geany - Compilation failed.
moved test.c file into /root/mnt just in case it can't find complier

tried setting Geany, to C - not sure if I did that is correctly
Geany error message -
C -Wall -c "test.c" (in directory: /root/mnt)
Compilation failed.
/bin/sh: C: command not found


also tried from command line in case of geany problems
same error message - command not found

DC

Puppy 2.13 installed on harddrive.
Intel P4
1gig of ram
a little bit of knowledge and I'm dangerous

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#4 Post by muggins »

devx_213.sfs should be located in /mnt/home, if you're using the cdrom, or a co-exist,
(or frugal), hard disk install.

if you type gcc -v , & bash says command not found , then possibly devx_213.sfs is in the wrong place, it's an incompleted/corrupt download, or maybe you've got a full(normal) hard disk install.

also, i've never used C to compile c programs. i just tested it on a simple program & it complained that -Wall was an unknown option, and a few other errors. (What actually is C a frontend for?)

anyway, compiling the same program with gcc -Wall test.c -o test worked fine.


User avatar
DC
Posts: 360
Joined: Sun 30 Apr 2006, 15:07
Location: Maidenhead, England

#6 Post by DC »

My puppy is loaded as a full harddrive install.
So, where does one put the file "devx_213.sfs"
do you need to set path statements anywhere?
do you need to tell the system to load "devx_213.sfs" ?

DC

Puppy 2.13 installed on harddrive.
Intel P4
1gig of ram
a little bit of knowledge and I'm dangerous

muggins
Posts: 6724
Joined: Fri 20 Jan 2006, 10:44
Location: hobart

#7 Post by muggins »

with a full puppy install of versions 1.xx, the developer .sfs module is just copied to / and puppy will find it. however with the pup2.xx series, you need to manually mount the devx_2xx.sfs then recursively copy the files to / .

if you check this link, see 2/3's down the page, where barry mentions c/c++ compiling:

http://puppyos.com/hard-puppy.htm

User avatar
paulh177
Posts: 975
Joined: Tue 22 Aug 2006, 20:41

#8 Post by paulh177 »

BK mentions two links there, I found that this is the link you need: http://www.murga.org/~puppy/viewtopic.php?t=8871
follow exactly the instructions in the second post (by "tony") and it should all burst into life

paul

User avatar
DC
Posts: 360
Joined: Sun 30 Apr 2006, 15:07
Location: Maidenhead, England

#9 Post by DC »

thanks to all for the help.
I can now compile. alough still bumbling along :D

DC
a little bit of knowledge and I'm dangerous

User avatar
Gekko
Posts: 443
Joined: Sat 22 Jul 2006, 09:57
Location: Sydney, New South Wales

#10 Post by Gekko »

www.beej.us he has an excellent beginner's guide to programming C, it says alpha because theres missing images and he doesnt know order of operations.

Order of Operations:

Parentheses
Exponents
Multiplication and Division
Addition and Subtraction

Yay me!

Post Reply