我是Linux的新手。我正在嘗試爲在線課程編譯代碼。在/home/MyName/Desktop/Cplusplus-Advanced-Source-Code/cplusplus-advanced-source-code/BitmapFileHeaders/Debug
生成文件是如下:bash:無法執行二進制文件:儘管二進制和Linux是64位,但執行格式錯誤
-include ../makefile.init
print-% : ; @echo $* = $($*)
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: BitmapFileHeaders
# Tool invocations
BitmapFileHeaders: $(OBJS) $(USER_OBJS)
@echo 'Building target: [email protected]'
@echo 'Invoking: MacOS X C++ Linker'
g++ -o "BitmapFileHeaders" $(OBJS) $(USER_OBJS) $(LIBS)
#"make print-OBJS", in command prompt, gives:
#OBJS = ./src/Fractal Creator - Hello World.o
@echo 'Finished building target: [email protected]'
@echo ' '
# Other Targets
clean:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(OBJS)$(C_UPPER_DEPS)$(CXX_DEPS)$(CPP_DEPS)$(C_DEPS) BitmapFileHeaders
[email protected] ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
在Debug/src
,有Fractal.o
。如果我嘗試./Fractal.o
,我會得到bash: ./Fractal.o: cannot execute binary file: Exec format error
。然而file Fractal.o
給
Fractal.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
不過,我的Ubuntu 15.10,這是64位的,所以這應該運行,對不對?我沒有寫這個代碼,所以我不知道作者是這樣寫的。如果我可以通過查找$(OBJS)
的位置來更改二進制文件的格式,會有幫助嗎?如果是這樣,我怎麼找到$(OBJS)
是哪裏?
'Fractal.o'只是'Fractal.cpp'的目標文件,而不是整個程序。我一眼就沒有完全理解你的makefile,但你基本上正在嘗試運行一箇中間構建文件。 – BoBTFish
它看起來像可執行文件被稱爲「BitmapFileHeaders」。在高級版之前,你應該至少做一個基本課程。 – molbdnilo
你怎麼知道「BitmapFileHeaders」是可執行文件? – user5739619