Bill21
Posts: 4
Joined: Sun Apr 05, 2020 7:29 pm

Is there any obvious reason why my raspberry pi 3b will not run an executable?

Sun Apr 05, 2020 7:46 pm

I got my raspberry pi to learn to code as a hobby. I tried a simple "hello world" program in the terminal. I got as far as creating an executable. However, the program wouldn't run. I tried the same exercise on my MacBook and it worked. I tried the exorcise again using some of the compilers that came native to Raspbian and got the same result. I have now copied arduino and netbeans onto my desktop but I can't install them because my machine won't run the executables. Can anybody make any sense out of this? thanks!

deepo
Posts: 548
Joined: Sun Dec 30, 2018 8:36 pm
Location: Denmark

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Sun Apr 05, 2020 8:02 pm

A MacBook and a Raspberry Pi do not share computer architecture, so an executable from one can't be executed on the other.
What are you trying to do?
Give us more info if you want help.

/Mogens

kerry_s
Posts: 569
Joined: Thu Jan 30, 2020 7:14 pm

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Sun Apr 05, 2020 8:03 pm

i'm thinking your talking about when you click on it? there is a setting in the file manager preference for that.
other wise, you need to make the file/script executable. right click> file properties or chmod +x your-file

DirkS
Posts: 10304
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Sun Apr 05, 2020 8:03 pm

Did you follow a tutorial? If so, can you please post a link.

What programming language?

How did you (try) to start your program?
the program wouldn't run
Any (error) messages?

User avatar
Paeryn
Posts: 2903
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Sun Apr 05, 2020 8:10 pm

Bill21 wrote:
Sun Apr 05, 2020 7:46 pm
I got my raspberry pi to learn to code as a hobby. I tried a simple "hello world" program in the terminal. I got as far as creating an executable. However, the program wouldn't run. I tried the same exercise on my MacBook and it worked. I tried the exorcise again using some of the compilers that came native to Raspbian and got the same result. I have now copied arduino and netbeans onto my desktop but I can't install them because my machine won't run the executables. Can anybody make any sense out of this? thanks!
We're going to need more information else we're likely to give answers that are irrelevant to your situation.

What programming language are you using, how did you compile your program, how did you try to run your program?

As to arduino and netbeans, where did you copy them from? At a guess you've downloaded the x86 versions which won't run on the RPi's Arm cpu.
She who travels light — forgot something.

Bill21
Posts: 4
Joined: Sun Apr 05, 2020 7:29 pm

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Mon Apr 06, 2020 4:26 pm

Hi

Thank you all for your replies. I wrote the "hello world" program on the terminal of my raspberry pi 3+ in "C" language. I used the GCC command to compile it into an executable. the executable wouldn't run. I repeated the exercise again on my raspberry pi 3+ using Geany that came native with the raspberry. I was able to compile that into an executable. The executable wouldn't run. I then wrote the "Hello World" program in the terminal of my MacBook. I used the gcc command to compile it into an executable on my MacBook. The program ran on my MacBook. I ran each of the programs in the computers that they were written on. Now I need to figure out why it didn't work on the raspberry pi. At the moment I am just trying to learn to code in c language. Ultimately, I want to program a robot that I am building.

I am also trying to install netbeans because I tried a simple "if" program in Geany and again in the terminal of my raspberry pi 3+. It couldn't find the "conio.h" folder both times. these compilers are referred to as light wait. Does that mean that they do not include the conio.h folder? I don't have the link that I sourced netbeans from. I thought it was their website. If you have a link to a reliable compiler or if you can help me to get up and running with one of the native compilers, I would be etarnally grateful.

I want to install the arduino compiler because I am hoping to include raspberry and arduino technology in the robotics project. I copied the package from the arduino website. https://www.arduino.cc/en/Main/Software I downloaded the version for Linux 32 bit.

It seems that I can't install the netbeans or the arduino compilers because the raspberry won't run the executables. I tried both clicking on the executable and using the run facility in the main menu with no joy. Kerry_s, please can you tell me what setting I need to change in the File Manager and how to get there as I am still finding my way around the raspbian OS?

For the "hello world" program I followed an article from "the MagPi essentials" entitled "Learn to code with "C" that I found on the raspberry website. I ran into this problem right away with the "hello world" program. For the "If" program I followed a tutorial from youtube. https://www.youtube.com/watch?v=K2RfUgCzZR8

User avatar
neilgl
Posts: 1905
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Mon Apr 06, 2020 4:33 pm

Ah, for the Arduino you wanted "Linux ARM 32 bits"

And for hello world, I started a Terminal (not code editor) and started the nano editor, then copied the code in from the Essentials Book, and saved. The compile and run worked ok (from the command line)

Code: Select all

[email protected]:~ $ gcc -o myprog hello.c
[email protected]:~ $ ./myprog
Hello world!

User avatar
Paeryn
Posts: 2903
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Mon Apr 06, 2020 4:47 pm

When you say it won't run your compiled program, what is the error message and again how did you run it (i.e. tell us exactly what you typed)?

As to conio.h, that's a DOS / Windows header file dealing mainly with console input/output, you won't find it on Linux. Some of that program will have to be re-written to use standard Linux libraries / functions.
She who travels light — forgot something.

jahboater
Posts: 5441
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Mon Apr 06, 2020 4:47 pm

Bill21 wrote:
Mon Apr 06, 2020 4:26 pm
I wrote the "hello world" program on the terminal of my raspberry pi 3+ in "C" language. I used the GCC command to compile it into an executable. the executable wouldn't run. I repeated the exercise again on my raspberry pi 3+ using Geany that came native with the raspberry. I was able to compile that into an executable. The executable wouldn't run.
What is wrong here? Are you doing this on a filesystem mounted with "noexec" or something strange?
After a successful compilation the C compiler sets execute permission for the resulting binary.
Please try simply:

Code: Select all

gcc hello.c -o hello
./hello
preferably in /home/pi
You do not need an IDE, its probably just confusing you.
If it doesn't work please post your hello.c program here.
it should look something approximately like this:

Code: Select all

#include <stdio.h>

int
main( void )
{
  puts( "Hello world!" );
}
and it runs like this:

Code: Select all

$ gcc hello.c -o hello
$ ./hello
Hello world!
$ 
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

Bill21
Posts: 4
Joined: Sun Apr 05, 2020 7:29 pm

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Tue Apr 07, 2020 10:12 pm

I tried ./hello and got Hello world! success! thanks people!

I'm still having trouble installing software on the raspbian OS. I want to install the arduino compiler on my Raspberry pi 3b which is running on Raspbian. I went into https://www.arduino.cc/en/Main/Software and downloaded the link, Linux Arm 32 bit to my MackBook. I didn't open it. I copied it strait to a memory stick and then to the raspbian desktop. I double clicked it and got an archive directory with 2 executables. arduino-linux-setup.sh and install.sh I double clicked arduino-linux-setup.sh which installed an arduino text editor on the desktop. I double clicked install.sh which opened an Execute File dialogue box. I clicked on "execute" which did nothing. I clicked on "Execute in Terminal", the terminal opened, scrolled through a bunch of commands and closed again. there was now a file, arduino-builder in the archive directory. If I double click it it opens an Execute File dialogue box. I clicked on "execute" which did nothing. I clicked on "Execute in Terminal" which also did nothing.

I opened the terminal and used the cd command to get into arduino-1.8.12-linuxarm.tar.xz because that was the file name on the desktop.
it returned Bash: cd: arduino-1.8.12-linuxarm.tar.xz: not a directory.
I typed ./arduino-1.8.12-linuxarm.tar.xz
it returned, Bash: cd: arduino-1.8.12-linuxarm.tar.xz: Permission denied.
I typed Sudo ./arduino-1.8.12-linuxarm.tar.xz
it returned, command not found.

Can I confirm that I am following the correct procedure to install software on the raspbian OS? And can anyone help me troubleshoot this problem?

jahboater
Posts: 5441
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Tue Apr 07, 2020 10:25 pm

Bill21 wrote:
Tue Apr 07, 2020 10:12 pm
I tried ./hello and got Hello world! success! thanks people!
There is a search path for executables: $PATH. By default (for security reasons) the current directory (.) is not on the path.
You can add . to the path with: export PATH=.:$PATH (OK on a single user Pi) or you can give the ./ explicitly each time.

Please note that "arduino-1.8.12-linuxarm.tar.xz" is not a directory and it is not an executable.
It is a directory tree that has been archived into a single file, then that file has been compressed.
You should start by retrieving the original tree with:

tar xvf arduino-1.8.12-linuxarm.tar.xz

In general you will find all this sort of thing very much easier from the command line.
Last edited by jahboater on Tue Apr 07, 2020 10:28 pm, edited 1 time in total.
"We are in the beginning of a mass extinction, and all you can talk
about is money and fairy tales of eternal economic growth."
- Greta Thunberg

kerry_s
Posts: 569
Joined: Thu Jan 30, 2020 7:14 pm

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Tue Apr 07, 2020 10:25 pm

no, your still doing it wrong.
a ".tar.xz" is a zipped file.

anyways it's in the repos you should be using that

Code: Select all

sudo apt install arduino
you should take some time to read the docs.
https://www.raspberrypi.org/documentation/

User avatar
neilgl
Posts: 1905
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Tue Apr 07, 2020 10:53 pm

Not sure if the latest version is in the repository? So you do want to go with the tar. As it says in MagPi 61 (after downloading it to "Downloads"):
Extract the file to your /opt directory , then open a Terminal and run the install.sh script to install.
cd Downloads/
tar -xf arduino-1.8.12-linuxarm.tar.xz
sudo mv arduino-1.8.12 /opt
sudo /opt/arduino-1.8.12/install.sh

Let me know if that fails

Bill21
Posts: 4
Joined: Sun Apr 05, 2020 7:29 pm

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Wed Apr 08, 2020 8:39 pm

OK, thanks everyone, I now have the Arduino compiler on my Raspberry. I definitely couldn’t have done it without you!

Paeryn wrote in relation to an if function program:

As to conio.h, that's a DOS / Windows header file dealing mainly with console input/output, you won't find it on Linux. Some of that program will have to be re-written to use standard Linux libraries / functions.

I’m trying to recreate a simple if command that I saw on YouTube. So it makes perfect sense that he may have been demonstrating it on a windows machine.

Does anyone know the equivalent header file to conio.h that Linux will recognise? Or, is it not that simple?

This is the code I got from the tutorial.

#include <stdio.h>
#include <conio.h>

int main (void)
{
int num1
int num2
printf (“enter 2 numbers”);
scanf (“%d%d”, &num1 &num2);

if(num1 == num2) {
printf(“they are equal);
}
if (num1 < num2) {
printf (“%d is less than %d”, num1, num2);
}
if (num1 > num2) {
printf (“%d is greater than %d”, num1, num2);
}

getch();
}

Remembering that this may have been written for a windows machine, can anyone help a novice like me with any corrections for a raspbian OS?

Ultimately I want to change the numeric input and output values to text values. So… again… any changes that anyone can suggest would be greatly appreciated.

User avatar
neilgl
Posts: 1905
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Wed Apr 08, 2020 9:41 pm

Delete the conio.h line. This works gcc -o myprog con2.c

Code: Select all

#include <stdio.h>
int main ()
{
  int num1;
  int num2;
  printf("enter two numbers\n");
  scanf ("%d %d",&num1,&num2);
  printf("Numbers are %d and %d\n",num1,num2);
  if(num1==num2) {
    printf("they are equal");
  }
  if(num1 < num2) {
    printf("%d is less than %d\n", num1, num2);
  }
  if(num1 > num2) {
    printf("%d is greater than %d\n", num1, num2);
  }
  return 0;
}

User avatar
neilgl
Posts: 1905
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Is there any obvious reason why my raspberry pi 3b will not run an executable?

Wed Apr 08, 2020 9:53 pm

And a strings version (con1.c)

Code: Select all

#include <stdio.h>
int main ()
{
   char name[30];
   char mycolour[50];
   printf("What is your name?\n");
   scanf ("%s",name);
   printf("What is your favourite colour?\n");
   scanf ("%s",mycolour);
   printf("Your name is %s\n",name);
   printf("Your favourite colour is %s\n",mycolour);
   return 0;
}
compile with gcc -o myprog con1.c
run with ./myprog
no IDE of any kind is involved.

Return to “Troubleshooting”