我有一个简单的问题。
这是我的 Makefile
#############################################################################
#
# Makefile for building the Long Range Navigator program
#
#############################################################################
PC = true
#PC = false
PWD := $(shell pwd)
#GUMSTIX_BUILDROOT = /home/irmabot/gumstix-buildroot
#BUILD_ARM = $(GUMSTIX_BUILDROOT)/build_arm_nofpu
#CROSS_COMPILE = $(BUILD_ARM)/staging_dir/bin/arm-linux-
#BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
#CROSS_COMPILE = $(patsubst %g++, %, $(wildcard $(BUILD_ARM)/staging_dir/bin/arm-linux-uclibc*-g++))
#CROSS_COMPILE = /home/irmabot/gumstix/gumstix-oe/tmp/cross/arm-angstrom-linux-gnueabi/bin/
CROSS_COMPILE = /home/babbage/marbotRelease/src/processors/longRangeNavigator/arm/arm-angstrom-linux-gnueabi/bin/
COMMON = ../../common
SHARED = Shared
I32 = /usr/include/x86_64-linux-gnu/c++/4.7/bits/
#ifeq ($(strip $(CROSS_COMPILE)),)
# $(error Unable to detect C++ Cross Compiler)
#endif
vpath %.c %.cpp $(COMMON) $(SHARED)
CPPFLAGS += -I . -I $(COMMON) -I $(SHARED) -I$(I32)
CFLAGS += -Wall -I$(I32)
ifeq ($(PC), true)
CPPFLAGS += -DPC -m32
CFLAGS += -DPC -m32
CC = g++
CXX = g++
OBJS = longRangeNavigator.o GALRN.o InternalMap.o MandamiFuzzyModel.o MembershipFunctions_1D.o Utils.o ../../common/configFile/configFile.o
else # else
TARGET_ARCH=-Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale
CC = $(CROSS_COMPILE)g++
CXX = $(CROSS_COMPILE)g++
OBJS = \
longRangeNavigator.o \
GALRN.o \
InternalMap.o \
MandamiFuzzyModel.o \
MembershipFunctions_1D.o \
Utils.o \
../../common/configFile/configFile.o
endif # endif
all: longRangeNavigator
longRangeNavigator: $(OBJS)
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions longRangeNavigator
depend .depend dep:
@echo "Creating dependencies ..."
$(CXX) $(CFLAGS) $(CPPFLAGS) -M *.cpp > .depend
FORCE:
.PHONY: FORCE
PREPROCESS.c = $(CXX) $(CPPFLAGS) $(TARGET_ARCH) -E -Wp,-C,-dD,-dI
%.pp : %.c FORCE
$(PREPROCESS.c) $< > $@
ifeq ($(strip $(filter clean, $(MAKECMDGOALS))),)
-include .depend
endif
我的问题是我在 amd64 机器上编译一个 32 位代码。这是输出
Creating dependencies ...
g++ -Wall -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -M *.cpp > .depend
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o longRangeNavigator.o longRangeNavigator.cpp
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o GALRN.o GALRN.cpp
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o InternalMap.o InternalMap.cpp
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o MandamiFuzzyModel.o MandamiFuzzyModel.cpp
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o MembershipFunctions_1D.o MembershipFunctions_1D.cpp
g++ -I . -I ../../common -I Shared -I/usr/include/x86_64-linux-gnu/c++/4.7/bits/ -DPC -m32 -c -o Utils.o Utils.cpp
g++ longRangeNavigator.o GALRN.o InternalMap.o MandamiFuzzyModel.o MembershipFunctions_1D.o Utils.o ../../common/configFile/configFile.o -o longRangeNavigator
/usr/bin/ld: Warning: size of symbol `_ZNSt8_Rb_treeISsSt4pairIKSsSsESt10_Select1stIS2_ESt4lessISsESaIS2_EED1Ev' changed from 75 in longRangeNavigator.o to 81 in ../../common/configFile/configFile.o
/usr/bin/ld: Warning: size of symbol `_ZNSt4pairIKSsSsED1Ev' changed from 63 in longRangeNavigator.o to 69 in ../../common/configFile/configFile.o
/usr/bin/ld: i386 architecture of input file `longRangeNavigator.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `GALRN.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `InternalMap.o' is incompatible with i386:x86-64 output
/usr/bin/ld: i386 architecture of input file `MandamiFuzzyModel.o' is incompatible with i386:x86-64
所以,很明显问题就在这里。我将 32 位代码与 64 位链接器链接到哪里。
g++ longRangeNavigator.o GALRN.o InternalMap.o MandamiFuzzyModel.o MembershipFunctions_1D.o Utils.o ../../common/configFile/configFile.o -o longRangeNavigator
我不完全理解这个动作在哪里执行的 Makefile。我只想添加 -m32 参数。