我知道其他人也有类似的问题,但我的问题似乎很独特,因为我没有犯明显的错误。我已查看其他问题,并在下面列出了所有必需的详细信息。
当我尝试执行使用 make 编译的二进制文件 (swetest.o) 时出现以下错误
bash: ./swetest.o: cannot execute binary file: Exec format error
这是我的系统信息
uname -a
Linux vXXXXXX 4.4.0-141-generic #167-Ubuntu SMP Wed Dec 5 10:40:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
这是我的文件信息
file swetest.o
swetest.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
这是我的编译器信息
gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
这是“Makefile”
CFLAGS = -g -Wall -fPIC # for Linux and other gcc systems
OP=$(CFLAGS)
CC=gcc #for Linux
# compilation rule for general cases
.o :
$(CC) $(OP) -o $@ $? -lm
.c.o:
$(CC) -c $(OP) $<
SWEOBJ = swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o swepcalc.o sweph.o\
swepdate.o swephlib.o swecl.o swehel.o
swetest: swetest.o libswe.a
$(CC) $(OP) -o swetest swetest.o -L. -lswe -lm -ldl
swemini: swemini.o libswe.a
$(CC) $(OP) -o swemini swemini.o -L. -lswe -lm
# create an archive and a dynamic link libary for SwissEph
# a user of this library will inlcude swephexp.h and link with -lswe
libswe.a: $(SWEOBJ)
ar r libswe.a $(SWEOBJ)
libswe.so: $(SWEOBJ)
$(CC) -shared -o libswe.so $(SWEOBJ)
clean:
rm -f *.o swetest libswe*
###
swecl.o: swejpl.h sweodef.h swephexp.h swedll.h sweph.h swephlib.h
sweclips.o: sweodef.h swephexp.h swedll.h
swedate.o: swephexp.h sweodef.h swedll.h
swehel.o: swephexp.h sweodef.h swedll.h
swehouse.o: swephexp.h sweodef.h swedll.h swephlib.h swehouse.h
swejpl.o: swephexp.h sweodef.h swedll.h sweph.h swejpl.h
swemini.o: swephexp.h sweodef.h swedll.h
swemmoon.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h
swemplan.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h swemptab.h
swepcalc.o: swepcalc.h swephexp.h sweodef.h swedll.h
sweph.o: swejpl.h sweodef.h swephexp.h swedll.h sweph.h swephlib.h
swephlib.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h
swetest.o: swephexp.h sweodef.h swedll.h
感谢帮助!