gpt4 book ai didi

c++ - 将 -m32 参数添加到 Makefile 命令

转载 作者:太空宇宙 更新时间:2023-11-04 14:00:08 25 4
gpt4 key购买 nike

我有一个简单的问题。

这是我的生成文件

#############################################################################
#
# 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 参数。

最佳答案

您还需要将 -m32 传递给链接器。一种方法是将此行添加到 Makefile 中:

LDFLAGS += -m32

LDFLAGS 是一个内置变量,只要链接器被 implicit rule 调用,它的值就会添加到链接器命令中。

关于c++ - 将 -m32 参数添加到 Makefile 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19645880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com