I just downloaded the GCC compile for C/C++. After compiling with the command gcc main.c -c -lGL -lGLU -lglut
I get a permission error which can be fixed by changing the permissions. I then get this error: bash: ./main.o: cannot execute binary file: Exec format error
. Will you help me fix this? Also if it helps I'm using C.
-Thank you in advance
file ./main.o
return? or ifmain.o
is not in the current directory, find the file and then run thefile
command on themain.o
to show what type of file it is. – mchid Sep 23 '21 at 19:00sudo apt install build-essential
? This is the recommended way to download and install GCC. – mchid Sep 23 '21 at 19:07.o
file suggests you added the-c
option, which suppresses linking to a final executable file – steeldriver Sep 23 '21 at 19:09build-essential
package after if that makes a difference – Dequog Sep 23 '21 at 19:35-c
(and optionally add-o progname
if you want the executable to be namedprogname
rather than the defaulta.out
). – steeldriver Sep 23 '21 at 19:47/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function _start': (.text+0x24): undefined reference to 'main' collect2: error: ld returned 1 exit status
– Dequog Sep 23 '21 at 19:57main.cpp
actually contain amain
function? Is it really C or is it C++ (as suggested by the.cpp
suffix)? If the latter, useg++
in place ofgcc
. If the former (C with a.cpp
suffix) you may need to add-xc
to direct gcc appropriately. – steeldriver Sep 23 '21 at 20:03main.c
and yes it does contain themain()
function also the-xc
command does nothing – Dequog Sep 23 '21 at 21:00-c
part which causes the other problem – Dequog Sep 24 '21 at 00:57