LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   compiling and running a c program in Linux (https://www.linuxquestions.org/questions/linux-newbie-8/compiling-and-running-a-c-program-in-linux-512640/)

myrto 12-21-2006 02:01 PM

compiling and running a c program in Linux
 
I just installed Linux 10.1 and I am really new at this. I wanted to know how to compile and run a program in c language. I tried using the bash shell but I couldn't find the right command.

Thanks.

reddazz 12-21-2006 02:15 PM

Hello and welcome to LQ. There is no such thing as Linux 10.1, so you need to mention the complete name of the distribution you are using. What is this C program you wish to compile. Is it one you created yourself or downloaded from somewhere to install on your system?

jschiwal 12-21-2006 02:27 PM

Read through "info gcc". ( Or enter "info:gcc" in the konqueror web browser )
Also make sure you have "make" installed.

The "glibc-html" package would do you well in referencing the glibc linux library.

Your local book store may have books on programming in C and C++ in Linux, which could help get you started as well.

You're message says you installed Linux 10.1, but that doesn't indicate which distro your version number is referencing. You may want to add your distro to your profile so we can tell and maybe provide better information on latter posts.

----

The moderator posted his message as I was writing mine. I had taken your question to mean that you wanted to learn to write C program and compile them in Linux.

raskin 12-21-2006 02:36 PM

I suppose that you use SuSE distribution of GNU/Linux, especially the one named "SuSE Linux 10.1"? And that you have written a program and want to compile it. And that you did not try running
Code:

man gcc
.

Then you should cd to directory with program and run
Code:

gcc -o program program.c
, which will produce executable file program, that can be run with command
Code:

./program
.

Try reading info gcc also.

Nevertheless, it is pointless to name version of your distribution without naming vendor, and it is always better to ask exact questions.

mushk45 12-21-2006 02:55 PM

Quote:

Linux 10.1
LOL!

you might need to install "gcc" also...

raskin 12-21-2006 02:59 PM

Well, if it were "Linux 6.10" I would definitely say "apt-get build-essentials", but it is not...

myrto 12-21-2006 05:11 PM

I actually found out that due to a mistake during installation I didn't have gcc installed and that was the source of the problem. When I tried to compile the program with gcc it returned "command not found" because of course it couldn't find it. Thanks.


All times are GMT -5. The time now is 09:41 AM.