C compiler

hi eeveryone,

does the BeageleBone Black have a C compiler ???

i want to controle a step by step motor using BBB with C language , and i’m wondering if the BBB has an integrated C compiler

gcc

thx ,sorry i have another question, i’m not failiar with LINUX , so can u help me with this , how can i write a C code on the terminal and excute it on my BBB ??

thx ,sorry i have another question, i’m not familiar with LINUX , so can u help me with this , how can i write a C code on the terminal and excute it on my BBB ?? what command i have to use???

Create your code in a file called, say, myprogram.c.

Then:-

    gcc -o myprogram myprogram.c

This will create a compiled program called myprogram which you can
execute by typing its name at the command prompt. For C++ you can do
the same using g++ instead of gcc.

For more complex programs and libraries it gets more involved.

And after you create the file for the first time, you will need to change its permissions
so that it is executable.
use an incantation like:
sudo chmod 755 myprogram.c

You will really need to become familiar with the basics of Linux, if you are
working on a Linux platform like the BeagleBone Black.

— Graham

myprogram.o

Yes.
sudo chmod 755 myprogram

or
sudo chmod 755 myprogram.o

— Graham

Graham, please do not tell fairy tails on this list!

$ echo '#include <stdio.h>' > hello.c
$ echo 'int main (void) { printf ("Hello, world!\n"); return 0; }' >> hello.c
$ cat hello.c
#include <stdio.h>
int main (void) { printf ("Hello, world!\n"); return 0; }
$ gcc -Wall -o hello hello.c
$ ./hello
Hello, world!
$ ls -l
total 12
-rwxrwxr-x 1 dw dw 7332 Mar 25 16:32 hello
-rw-rw-r-- 1 dw dw 80 Mar 25 16:31 hello.c
$

No chmod needed, no myprogram.o there, why the sudo???

No chmod needed IF you precede the command with a dot slash “./”. So when you run a regular Linux command do you have to type this dot slash ? No because chmod +x is run on the executable at some point . . .

So be nice to fellow group users who actually know what they’re talking about, and have been on this list a lot longer than you.

Maybe we need to learn what ./ does… It has absolutely nothing to do with a files permissions or whether it’s executable or not. It’s use is regarding the lack of the current directory “.” in one’s PATH variable. Umask is (largely) what controls what permissions a file is created with. ls -al total 12 drwxr-xr-x 2 mike mike 4096 Mar 25 17:07 . drwxr-xr-x 37 mike mike 4096 Mar 25 16:46 … -rw-r–r-- 1 mike mike 78 Mar 25 16:47 hello.c umask 0022 gcc -Wall -o hello hello.c ls -l total 12 -rwxr-xr-x 1 mike mike 6696 Mar 25 17:08 hello -rw-r–r-- 1 mike mike 78 Mar 25 16:47 hello.c hello bash: hello: command not found ./hello Hello, world! umask 0137 gcc -Wall -o hello hello.c ls -l total 12 -rw-r----- 1 mike mike 6696 Mar 25 17:09 hello -rw-r–r-- 1 mike mike 78 Mar 25 16:47 hello.c hello bash: hello: command not found ./hello bash: ./hello: Permission denied ls -l total 12 -rw-r----- 1 mike mike 6696 Mar 25 17:09 hello -rw-r–r-- 1 mike mike 78 Mar 25 16:47 hello.c chmod 0750 hello ls -l total 12 -rwxr-x— 1 mike mike 6696 Mar 25 17:09 hello -rw-r–r-- 1 mike mike 78 Mar 25 16:47 hello.c ./hello Hello, world! umask 022 umask 0022 Mike

No, Mike is absolutely correct. dot’s meaning in this context is current directory, and slash is just a path modifier / separator. Putting the file in ones $PATH would solve the “problem” of having to use dot slash I’ve know this forever, I do not know why I was thinking that chmod +x would solve that “issue”, because it wont.

I do recall at some point perhaps not too long ago that changing file permissions to executable was required. But now days this does not seem to be the case . . . I’ve always in the last several years use ./executable until I put the executable into my local path . . .

Im guessing that perhaps gcc’s -o option now days enables the executable bit on the output file ? I haven’t looked into that however.

Nothing at all to do with gcc, reread what I already posted… Mike

Nothing at all to do with gcc, reread what I already posted…

Your system, and mine behave nothing alike. For instance if I attempt to run an executable without using dot slash prefixed. The executable will simple fail silently.

william@beaglebone:~/ti$ gcc test.c -o test
william@beaglebone:~/ti$ test
william@beaglebone:~/ti$ ./test
32.540001

william@beaglebone:~/ti$ sudo ln -s /home/william/ti/test /usr/bin/test
william@beaglebone:~/ti$ test
william@beaglebone:~/ti$ cd …
william@beaglebone:~$ test
william@beaglebone:~$ sudo test
32.540001

So, it’s a permissions issue. . .

chmod +x test

Regards,

chmod +x test

Regards,

Yeah, thats what I thought too, but it doesn’t work. I suspect in my case the symbolic link is getting in the way. But thats not the only issues thats going on. Looking into it

Exactly, yet you haven’t show any of the file permissions in your above foray. Again I’ll say it umask is largely what controls how permissions are set when files are created. This is basic *nix 101… Mike

umask has no effect on the current situation. None, period, zip.