libmps-iLog.a:无法读取符号:文件格式错误

时间:2015-09-01 13:54:15

标签: c++ makefile

我将名为CplusplusObjects的文件夹中的所有cpp文件编译成libmps-cplusplus.a。当我尝试使用libmps-cplusplus.a在另一个makefile中创建共享对象时,我得到libmps-cplusplus.a:无法读取符号:文件格式错误**错误。

在搜索类似的问题时,我发现这个问题与32位和64位版本的混合有关,但我在这两个make文件中都特别提到了64位。

makefile for CplusplusObjects

doctrine:
    orm:
        default_entity_manager: default
        entity_managers:
            default:
                ...
                metadata_cache_driver: apc
                query_cache_driver: apc
                result_cache_driver: apc
            another_entity_manager:
                ...
                metadata_cache_driver: apc
                query_cache_driver: apc
                result_cache_driver: apc

makefile for jnibridge

#
# Makefile : C++Objects
#
# Explicit setting of SHELL
SHELL=/bin/sh
JAVA_HOME=/usr/java/jdk1.7.0_79
WA_ROOT=/localdata/sunny/CDDmain/sw

# source files.
SRC = Aggregations.cpp BasicRouter.cpp cac.cpp CapacityRouting.cpp 

OBJS = $(SRC:%.cpp=%.o)

OUT = $(WA_ROOT)/build/lib/libmps-Cplusplus.a

# include directories
INCLUDES = -I$(JAVA_HOME)/include \
-I$(JAVA_HOME)/include/linux \
-I $(WA_ROOT)/mps/iLog/DiverseRoute -I $(WA_ROOT)/mps/iLog/jniBridge \
-I $(WA_ROOT)/mps/iLog/C++Objects -I $(WA_ROOT)/mps/iLog/Simulator

# C++ compiler flags (-g -O2 -Wall)
#CCFLAGS = -g
CCFLAGS = -m64 -DBIT64 -shared -fPIC -g -ansi -c

# compiler
CC = /usr/bin/g++


# System defined library paths and names
#SYSLIBS=-L../ -L/usr/local/lib -lm
SYSLIBS= 

# User defined library paths and names
LIBS = 

# compile flags
#LDFLAGS = -g
LDFLAGS =

AR = /usr/bin/ar -rvu

.SUFFIXES: .cpp

.cpp.o : 
    $(CC) $(CCFLAGS) $(INCLUDES) $*.cpp -o $*.o

all:$(OUT)
$(OUT) : $(OBJS)
    $(AR) $(OUT) $(OBJS)
    /usr/bin/ranlib $(OUT)

clean:
    rm -f $(OBJS) $(OUT) Makefile.bak 

这是最终make文件的输出

#
# Makefile : jniBridge
#
# Explicit setting of SHELL
SHELL=/bin/sh
JAVA_HOME=/usr/java/jdk1.7.0_79
WA_ROOT=/localdata/sunny/CDDmain/sw

# source files.
SRC = AutomatedDelayAnalysis.cpp AutomatedAnalysis.cpp /     DelayAnalysis.cpp  

OBJS = $(SRC:%.cpp=%.o)

OUT = $(WA_ROOT)/build/lib/libmpsAlgo.so

# include directories

INCLUDES = -I$(JAVA_HOME)/include \
-I$(JAVA_HOME)/include/linux \
-I $(WA_ROOT)/mps/iLog/DiverseRoute -I $(WA_ROOT)/mps/iLog/jniBridge \
-I $(WA_ROOT)/mps/iLog/C++Objects -I $(WA_ROOT)/mps/iLog/Simulator \
-I$(WA_ROOT)/3rdParty/csim/csim20_64bit/gpp/lib

# C++ compiler flags (-g -O2 -Wall)
#CCFLAGS = -g
CCFLAGS = -m64 -DBIT64 -ansi -c

# compiler
CC = /usr/bin/g++

# System defined library path and names
#SYSLIBS=-L../ -L/usr/local/lib -lm
SYSLIBS= 

# User defined library paths and names
LIBS = -L$(WA_ROOT)/build/lib -L$(WA_ROOT)/3rdParty/csim/csim20_64bit/gpp/lib \ -lmps-Cplusplus 

# compile flags
#LDFLAGS = -g
LDFLAGS = -m64 -DBIT64

.SUFFIXES: .cpp

.cpp.o : 
    $(CC) $(CCFLAGS) $(INCLUDES) $*.cpp -o $*.o

all:$(OUT)
$(OUT) : $(OBJS)
    $(CC) -o $(OUT) $(LDFLAGS) $(OBJS) $(LIBS) 

clean:
    rm -f $(OBJS) $(OUT) Makefile.bak 

1 个答案:

答案 0 :(得分:0)

Objdump -af libmps-Cplusplus.a如@EtanReisner所建议的libmps-Cplusplus.a表示,有一个名为OsrpGroomingCapacityPlanning.o的文件被编译为文件格式elf32-i386。这导致"无法读取符号:文件格式错误**错误"。为了解决这个问题,我必须从存档中删除OsrpGroomingCapacityPlanning.o并手动编译它并将其与其他.o文件一起再次存档。