monahanz
Posts: 10
Joined: Sat Sep 13, 2014 5:17 pm

Newbie, cannot get a Hellow World to run. please help

Tue Jan 02, 2018 7:24 pm

New here, sorry about this basic question.
I have a Hellow World .c file in a folder /Home/Pi/Public/C_programs called Test1.c

With Geany I can compile fine but it does not seem to make an executable file that runs. In the Geany Set Build Commands I have:-

Compile: gcc -Wall -c "%f" Working Directory: /home/Pi/Public/C_Programs

Build: gcc -Wall -o "%f" Working Directory: /home/Pi/Public/C_Programs

Execute: Working Directory: /home/Pi/Public/C_Programs

Within the sh window I get:- sudo /home/Pi/Public/C_Programs/%e/Test1: Command not found

What is the simple thing I have wrong here?
John
:roll:

User avatar
scruss
Posts: 1703
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Newbie, cannot get a Hellow World to run. please help

Tue Jan 02, 2018 10:45 pm

Your /Home/Pi should be /home/pi — case matters!

Also, what part is running under sudo? You don't need sudo to build and run commands.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

jbudd
Posts: 627
Joined: Mon Dec 16, 2013 10:23 am

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 1:44 am

Within the sh window I get:- sudo /home/Pi/Public/C_Programs/%e/Test1: Command not found
Apart from the upper case issue, do you really have a folder %e ?

User avatar
scruss
Posts: 1703
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 2:17 am

jbudd wrote:
Wed Jan 03, 2018 1:44 am
Apart from the upper case issue, do you really have a folder %e ?
They're Geany's substitution variables:
Screenshot from 2018-01-02 21-14-24.png
geany
Screenshot from 2018-01-02 21-14-24.png (18.77 KiB) Viewed 749 times
If you open a Geany template, it'll set these values correctly for more languages. The ones I showed above were from Geany's ‘main.c’ template.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

rhubarbdog
Posts: 26
Joined: Mon Dec 11, 2017 9:58 pm

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 12:15 pm

Geany is buggy. I have many years experience in computing . When i bought a raspberry pi 3 as a device for my friends child to learn programming. I tried geany and recomended it not be used.
Get any editor with syntax high lighting. Use a terminal to compile and build.
Do your debugging with gdb. Just set your break points and run your program.

rhubarbdog
Posts: 26
Joined: Mon Dec 11, 2017 9:58 pm

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 12:27 pm

I can't verify this but it appears that %e expands to the file name without .c to run the command in a terminal type
/home/pi/Public/C_Programs/Test1

If geany has an execute button type
/home/pi/Public/C_Programs/%e

Stop typing sudo before your commands. sudo gives you super user authority (root privileges). You're going to break your system if you don't get out of the habbit of typing sudo before each command.

jahboater
Posts: 2724
Joined: Wed Feb 04, 2015 6:38 pm

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 12:45 pm

Try outside of geany for interest:-

cd Public/C_programs

cc Test1.c -o test1

./test1

alternatively just type ...

make Test1

Now you know it really does work, you can focus on building it in the IDE.

jbudd
Posts: 627
Joined: Mon Dec 16, 2013 10:23 am

Re: Newbie, cannot get a Hellow World to run. please help

Wed Jan 03, 2018 12:56 pm

sudo /home/Pi/Public/C_Programs/%e/Test1: Command not found
It's certainly true that I know nothing of Geany or it's substitution variables. However that command line looks like sudo is attempting to find /home/Pi/Public/C_Programs/%e/Test1. If this is running within Geany and %e evaluates to Test1 then sudo is looking for /home/Pi/Public/C_Programs/Test1/Test1

So is /home/pi/Public/C_Programs/Test1 an executable file or a directory? What does the command "file ~/Public/C_Programs/Test1" show you?

User avatar
scruss
Posts: 1703
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Newbie, cannot get a Hellow World to run. please help

Thu Jan 04, 2018 3:08 am

rhubarbdog wrote:
Wed Jan 03, 2018 12:15 pm
Geany is buggy.
‘citation needed’, as the kids today might say. While I don't like it as an IDE, it works for the small projects I throw at it.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

monahanz
Posts: 10
Joined: Sat Sep 13, 2014 5:17 pm

Re: Newbie, cannot get a Hellow World to run. please help

Fri Jan 05, 2018 6:05 am

Thanks for the fast reply everybody. This group is great. I come from the Intel/Edison group that takes days for a response!
First I actually had “/Home” as /home – I just typed it wrong in the forum message.
:oops:
I now notice that I cannot get make working . Below is my configuration file. What needs to be corrected to have an executable in /home/pi/Public/C_Programs

Thanks
John
Image
Image
Attachments
Geany2.jpg
Geany2.jpg (97.25 KiB) Viewed 584 times
Geany1.jpg
Geany1.jpg (103.27 KiB) Viewed 584 times

rhubarbdog
Posts: 26
Joined: Mon Dec 11, 2017 9:58 pm

Re: Newbie, cannot get a Hellow World to run. please help

Fri Jan 05, 2018 9:11 am

Remove that sudo from your execute command if if needs any thing other than ./%e or /home/pi/Public/C_Programs/%e then its bash

rhubarbdog
Posts: 26
Joined: Mon Dec 11, 2017 9:58 pm

Re: Newbie, cannot get a Hellow World to run. please help

Fri Jan 05, 2018 9:13 am

If you really need to use sudo from geany then it should be gksudo

User avatar
scruss
Posts: 1703
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Newbie, cannot get a Hellow World to run. please help

Fri Jan 05, 2018 3:50 pm

Please give us the results of this command:

Code: Select all

ls -l /home/pi/Public/C_Programs
Geany's warning about Invalid Working Directory “/home/pi/Public/C_Programs” makes me think that folder doesn't exist. You can fix that with:

Code: Select all

mkdir -p /home/pi/Public/C_Programs
Have you tried Geany's File → New from template → main.c option? It sets all the build and run options, so you can save your C where you want and it handles all the folders and compilation variables.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

monahanz
Posts: 10
Joined: Sat Sep 13, 2014 5:17 pm

Re: Newbie, cannot get a Hellow World to run. please help

Fri Jan 05, 2018 7:06 pm

Thanks rhubarbdog , removing the sudo did the trick!

Return to “Beginners”

Who is online

Users browsing this forum: ed74 and 27 guests