• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

"bash cannot execute binary file"

Alex

Diamond Member
testing out gcc in mandrake linux 9.1:

make simple hello world program main.c

compile:

gcc -o main main.c

execute:

bash main

and i get the error in the subject... help!
 
I beleive that you only use "bash filename" when executing a script.

That's the same as putting the #!/bin/bash at the beginning of the script file. (I beleive, never tried to bash filename anything before)


Just do:

./main

If your in the same directory as the executable.
 
Originally posted by: drag
I beleive that you only use "bash filename" when executing a script.

That's the same as putting the #!/bin/bash at the beginning of the script file. (I beleive, never tried to bash filename anything before)


Just do:

./main

If your in the same directory as the executable.

i get a similar error... ill post later on today when i can...

also i chmodded it to +x so it should execute...
 
gcc makes compiled binaries executable by default. Just type their path to run them (using "./" if they're in the current directory).

Segmentation Fault? 😉
 
Try this bash script.

#!/bin/bash

echo '
#include <stdio.h>

main()
{
printf ("Hello World!\n");
}' > ./main.c

gcc -o main ./main.c

./main

Put that script in a plain text file called test.sh

then:

chmod 777 test.sh

./test.sh

hopefully that works.

edit: forgive me for the brain fart. I thought it was funny to write a script that wrote and compiled it's own c program.

The actual c program is:
#include <stdio.h>

main()
{
printf ("Hello World!\n");
}

That should work, is yours different?
 
Back
Top