To convert Puppy into a complete compiler environment you will need to get the compiling addon file that corresponds with the version of Puppy that you are using, e.g. for Puppy 2.14 devx_214.sfs. So start downloading now, then read while you wait....
Download here:
For most every type of Puppy install (live-cd, frugal), save or copy the file to /mnt/home(if it doesn't exist then you probably have a full hard drive install, see below). This is where your personal storage file is, e.g. pup_save.2fs or pup001. Now if you're using Puppy 2.x and haven't saved your session somewhere then you need to do that first for Puppy to recognize the devx file. Now simply reboot back into Puppy to start compiling.
But for a full/option-2/normal hard drive install to Linux partition with Puppy 2.x, then follow the instructions at the bottom of Barry's page∞ for now but check back here later for a shortcut.
see also: http://www.murga-linux.com/puppy/viewtopic.php?t=16780∞
Now that you've installed you devx module, it is time to test it to see if it works.
Open up rxvt and type 'cc' it should spit this back at you
cc: no input files
If it tells you 'command not found' then it has not installed properly.
Save the following as test.c
If using Geany, set it it to C and test compile first
int main()
{ 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
gcc test.c -o test
this will create a runnable file called "test"
the command
./test
will run it . . .
find a good tutorial e.g.
What does Compiling mean?
compiling...
you can write programs in assembler, which is almost "perfect" in the eyes of a computer, very close to binary code.
lda 02
sta #c000
lda #c001
cmp #c000
bne d000
But this is difficult to understand, in C it might look like this:
a=2;
b=c;
if (a != b){
my_subroutine();
}
This is easier to understand (high-level language), a simple comparison of two numbers, and depending on the result (if they are different), a sub-program is executed.
As computers do not understand "if" and don't have variables (C) but only a stack (assembler), the code must be translated from C to assembler or even better directly to binary code (assembler itself is not binary, but a very simple form of a "high-level-language" very close to binary code).
This translation is "compiling".
If you open the resulting "code" in a hexeditor, you will only see binary code, values from 0 to 255 "wildly mixed". The computer can understand this code, but no human can.
Why Compiling programs
How to Compile programs
Puppy 2
If you're running a liveCD or frugal/poor-man's/option-1/coexist install, stick the devx file in /mnt/home, in the same directory as pup_save.3fs and co.
That's always been the way to do it with these installations. You only need to put it in root when using an option-2 full-hd install.
Now, if you've got a multisession, I don't know exactly how that works. I imagine the same as the option-2 setup.
If you do have one of the latter two, did you say you were putting it in /root? If so, and that doesn't work, try / instead. As in the actual root, not /root.
The development environments for Puppy 2.00 and 1.xx are available at http://puppylinux.org/user/downloads.php?cat_id=12∞ . devx_201.sfs is at http://www.puppyos.com/test/∞ (and at my mirror page: http://s3.amazonaws.com/puppy/index.html∞ )
To use it, put the devx_xxx.sfs or usr_devx.sfs file in the same place as your pup_save file, and reboot.
Note that the ` on each side of mplayer is a back quotes above the tab button, not regular single quotes. This tells it to run the ldd command on the results of the which command, so you don't have to first locate mplayer (in this example - replace mplayer with the program you wish to check dependencies for), the results of which are piped through the grep command which only lets through the results containing the word 'not'
Example with results:
Of course you could type in
substituing your app and its path for /etc/local/bin/mplayer, and scan the resulting list manually (thanks for MU, or was it Lobster, who pointed out this simple trick... I like being lazy).
To Compile:
....If you run into problems
This little detail is not on the "compiling for puppy" but it's a fairly important one:
a lot of Makefiles will leave the "add debug symbol" option of gcc enabled (it's "-g"). This means that a alot of "text" information is added to your program to facilitate debugging, increasing the program file significanlty.
When you compile for puppy before typing make (but after the ./configure step if it's part of the compiling steps) you should open Makefile and look for a line that sets the C flags (usually CFLAGS = ....).
if the line include -g remove it and see how much space is gained. This will NOT change the behavior of the program.
There are other optimizations that can be enabled, such as changing the optimizer setting. I find of a lot of program use -O2 by default, changing it to -Os will usually make a smaller program. In theory changing optimizer settings should not change the behavior of your program, however it is possible that it can have subtle side effects that the original programmer didn't test for.
I'm really happy to see the source-sorcerer project, because now we can go in and check how each package was built, and make sure that each build is optimized.