Gcc Exec Format Error
ran exec format error in linux test.exe on the command line, it gave me: c cannot execute binary file Exec format error. Wrong Architecture. how should I fix this error? thanks cannot execute binary file exec format error sjang May 21, 2008 at 6:06pm UTC bnbertha (401) It's difficult to say without seeing the contents of test.cpp. However assuming your .cpp is C++ code, you're compiling with a C compiler, try using g++ instead of gcc. May 21, 2008 at 7:00pm UTC sjang (3) Hi test.cpp is a c++ program. I tried g++ -c -o test.exe test.cpp but still got the same error. Any ideas? thanks sjang May 21, 2008 at 8:17pm UTC Duoas (10453) The problem might be because you keep using the -c flag. You can't directly execute an .obj file, no matter what its extension. g++ test.cpp -o test If that doesn't fix it, then exactly what OS, hardware, and version of GCC are you using? May 21, 2008 at 8:31pm UTC sjang (3) Hi getting rid of that -c fixed it. Thanks for helps! sjang Topic archived. No new replies allowed. C++ Information Tutorials Reference Articles Forum Forum BeginnersWindows ProgrammingUNIX/Linux ProgrammingGeneral C++ ProgrammingLoungeJobs Home page | Privacy policy© cplusplus.com, 2000-2016 - All rights reserved - v3.1Spotted an error? contact us
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up compiled C file not executable up vote 1 down vote favorite So when I try to run a compiled C program http://www.cplusplus.com/forum/unices/2041/ on my school's "hercules" server, it runs as I would normally expect it to. However, I've got an assignment that requires the use of forks, and running programs that fork on that server is forbidden, instead, I am to run them by remotely connecting to one of several Linux machines and running it there, from command line However, any attempt to do so gives me this error: shell2: Exec format error. Binary file http://stackoverflow.com/questions/21821720/compiled-c-file-not-executable not executable. Altogether, my command prompt looks like this: a049403[8]% shell2 shell2: Exec format error. Binary file not executable. I've got the shell2 file in the working directory, when I type "ls" it shows it with the * character indicating it is notionally an executable. I've tried setting its permissions to 777. It produces the same error for other C programs which I have been working with and running, and "hercules" can run the exact same file without any difficulties or complaints. My make file for this particular program looks like this: all: shell2 Basics.o: Basics.c Basics.h cc -c Basics.c doublinked.o: doublelinked.c doublelinked.h cc -c doublelinked.c main.o: main.c Basics.h doublelinked.h cc -c main.c shell2: main.o Basics.o doublelinked.o cc main.o Basics.o doublelinked.o -o shell2 clean: rm -f *o shell2 ...and if I re-run the makefile it seems to build the program with no difficulties. So, and reason an environment that can compile C programs would be unable to run them? Any likely workarounds? c linux unix compilation share|improve this question edited Apr 30 '14 at 17:51 Brandon Wamboldt 9,005103671 asked Feb 17 '14 at 5:50 user1299656 1061312 2 What does file yourprog /bin/sh say on the target machine? If it doesn't say much the same thing, the trouble is what the error message says — your binary was pr
here for a quick overview of the site Help Center http://stackoverflow.com/questions/32192024/exec-format-error-when-compiling-android-kernel Detailed answers to any questions you might have Meta Discuss http://superuser.com/questions/973566/compiler-tools-execv-and-exec-format-error-under-s390x-chroot the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss exec format Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Exec format error when compiling android kernel up vote 0 down vote favorite I am trying to build a exec format error kernel for Xperia SP. First I have git-cloned the kernel source from here: https://github.com/Tomoms/android_kernel_sony_msm8x60 then git-cloned this toolchain: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7 then I went to: KERNEL_FOLDER/arch/arm/configs and copied msm8960_defconfig (as i think Xperia SP has msm8960) to root of KERNEL_FOLDER and renamed it to .config then I opened the terminal in the KERNEL_FOLDER directory and typed make ARCH=arm CROSS_COMPILE=~/toolchains/arm-eabi-4.7/bin/arm-eabi- and got this CHK include/linux/version.h CHK include/generated/utsrelease.h HOSTCC scripts/basic/fixdep make[1]: `include/generated/mach-types.h' is up to date. CC kernel/bounds.s /home/pc/toolchains/arm-eabi-4.7/bin/arm-eabi-gcc -Wp,-MD,kernel/.bounds.s.d -nostdinc -isystem /home/pc/toolchains/arm-eabi-4.7/bin/arm-eabi-gcc -print-file-name=include [Errno 8] Exec format error -I/home/pc/android/kernel/android_kernel_sony_msm8x60/arch/arm/include -Iarch/arm/include/generated -Iinclude -include /home/pc/android/kernel/android_kernel_sony_msm8x60/include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-msm/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Wno-format-security -fno-delete-null-pointer-checks -Os -fstack-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fomit-frame-pointer -g -mtune=cortex-a7 -mfpu=neon-vfpv4 -fgraphite -floop-parallelize-all -ftree-loop-linear -floop-interchange -floop-strip-mine -floop-block -DKBUILD_STR(s)=#s -DKBUILD_BASENAME=KBUILD_STR(bounds) -DKBUILD_MODNAME=KBUILD_STR(bounds) -fverbose-asm -S -o kernel/bounds.s kernel/bounds.c [Errno 8] Exec format error make[1]: *** [kernel/bounds.s] Error 8 make: *** [prepare0] Error 2 androi
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Super User Questions Tags Users Badges Unanswered Ask Question _ Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Compiler tools, execv and “exec format error” under s390x chroot up vote 0 down vote favorite I have a Debian 8 x86_64 machine with two chroot environments. The first is armel and the second is s390x. armel was installed last week, and s390x was installed recently. armel is fine both before and after the s390x install. But I'm catching errors when compiling under the newly installed s390x. # chroot debian-s390x # g++ -dumpmachine s390x-linux-gnu # cd /home/cryptopp-5.6.3/ # make g++ -DNDEBUG -g2 -O2 -pipe -c osrng.cpp g++: error trying to exec '/usr/lib/gcc/s390x-linux-gnu/5/cc1plus': execv: Exec format error GNUmakefile:382: recipe for target 'osrng.o' failed make: *** [osrng.o] Error 1 I can't find any information when searching for /usr/lib/gcc/s390x-linux-gnu/5/cc1plus': execv: Exec format error. I did find some reading related to cc1plus, but I don't see where there's a problem with the installation: # file /usr/lib/gcc/s390x-linux-gnu/5/cc1plus /usr/lib/gcc/s390x-linux-gnu/5/cc1plus: ELF 64-bit MSB executable, IBM S/390, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld64.so.1, for GNU/Linux 2.6.32, BuildID[sha1]=aaa1e442e47e5e41c36b70d5e6a8f538da4ca3e7, not stripped I also performed a reinstall of g++ with apt-get install --reinstall g++, but it did not help. What is the issue, and what is the solution? EDIT: this may be the issue, or may be a related issue: Debian Bug 684909: qemu-system-s390x is broken, no bootloader 's390-zipl.rom'. I don't believe its due to the project I am trying to compile: # cat test.cxx #include