LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem getting my C program to run (https://www.linuxquestions.org/questions/linux-newbie-8/problem-getting-my-c-program-to-run-930221/)

sraweber369 02-19-2012 01:10 PM

Problem getting my C program to run
 
I am having problems getting my C program to run it compiles OK but when I try to run it from a terminal I get an error command not found here is some output

linux-dhj2:/usr/lib/cprogs # cat helloworld.c
#include <stdio.h>
main()
{
printf("hello world\n");
}



linux-dhj2:/usr/lib/cprogs # gcc -o helloworld helloworld.c
linux-dhj2:/usr/lib/cprogs # chmod 744 helloworld
linux-dhj2:/usr/lib/cprogs # helloworld
If 'helloworld' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf helloworld
linux-dhj2:/usr/lib/cprogs #

I know C programming fairly well having worked on a comercial mfc C++ project (mfc sucks)

what am I doing wrong

johnsfine 02-19-2012 01:13 PM

In Linux, your current directory is normally not in your path. Many people believe there are important safety benefits from not having the current directory in the path.

So you need to type
Code:

./helloworld
in order to run an executable named helloworld in your current directory.

Heraton 02-19-2012 01:14 PM

Hi!

Try this one!
Code:

./helloworld
most likely your current working directory is not on your search path (for security reasons)...


Regards,

Heraton

sraweber369 02-19-2012 01:17 PM

Thanks that helped.


All times are GMT -5. The time now is 05:57 PM.