Click to See Complete Forum and Search --> : Compile C program on Mandrake


hiker
12-06-2002, 02:02 PM
I have a very simple C program source (that just reads and writes to a file) that I want to compile with Mandrake 8.1. Can some one please give me instructions to compile and create an executable from the command shell?

bwkaz
12-06-2002, 03:21 PM
Pretty simple. ;)

gcc -o executablename sourcename.c

Where sourcename.c is whatever you called the source file, and executablename is whatever file you want it to write the output to. If you leave out the -o executablename part, the default name is a.out.

To run the program, do a ./executablename (or whatever you call it).

If any of this doesn't work, post what you're typing and the errors you're getting. Copy and paste from the command shell would be ideal. ;)

hiker
12-06-2002, 05:06 PM
Received:
gcc: command not found

I wonder if there an install option I need or is there compiler download somewhere?

Thanks

yosarian
12-06-2002, 05:26 PM
GCC is the compiler and it looks like its not currently intalled on your system. You should be able to intall it off of one of the Mandrake CDs.

hiker
12-06-2002, 05:30 PM
Can you be more specific? I have 2 cds and no hardcopy documentation. I guess I could reinstall the whole distro and select every option and hope that gets it.

Edit update:
Reinstalled and selected the development package and I'm up and compiling and lovin' linux.
Thanks

yosarian
12-06-2002, 08:21 PM
Sorry I missed your last post and you had to reinstall. If you use one of GUIs like KDE there should be some kind of Softdrake utility or something along those lines that would let you browse the available packages. In console the rpm command may help, but I couldn't give you the specifics. Try 'man rpm'.

Glad you got it working though!:)

bwkaz
12-07-2002, 09:25 AM
In the future if you have to add anything else off your CDs, there is an rpmdrake program that was hopefully installed. It's named "software manager" on most of my Mandrake desktops. It'll let you choose any package you want, ask you for the CDs, and then install any dependencies, plus the package itself.

But I don't know how well it works with packages that were downloaded. I know it works well with anything on the original CD, though.