2013-10-28 66 views
1

我有一個簡單的問題。添加-m32參數到Makefile命令

這是我的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) $< > [email protected] 

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 

因此,很明顯的問題是在這裏。在哪裏我連接一個64位連接器的32位代碼。

g++ longRangeNavigator.o GALRN.o InternalMap.o MandamiFuzzyModel.o MembershipFunctions_1D.o Utils.o ../../common/configFile/configFile.o -o longRangeNavigator 

我不完全理解Makefile這個動作是否完美。 我只想添加-m32參數。

+0

調用鏈接器命令其值'LDFLAGS' 。但是設置'CXX = g ++ -m32'更容易。 –

回答

0

您需要將-m32也傳遞給鏈接器。你可以通過添加此行到您的Makefile做的一個辦法:

LDFLAGS += -m32 

LDFLAGS是一個內置變量被添加到只要連接通過implicit rule

+0

我知道了。我只是不知道隱含的規則。 非常感謝! –

0

如果你有yum或apt,你可以安裝gcc 32,並使用它。請同時使用in或64或32.

相關問題