makefile问题:g++编译后,报错“file not recognized: File format not recognized”,求高人!!
先贴上makefile文件:
CC = g++
#############################################################
HOMEPATH = /home/bppf_eas/test
OBJPATH = $(HOMEPATH)/obj
LIBPATH = $(HOMEPATH)/lib
BINPATH = $(HOMEPATH)/bin
SRCPATH = .
INCPATH = .
LINKOBJ = -lpthread
COMMONCPP2_COMPILE_FLAG = -pedantic -Wall -g -O2
CXXFLAGS = $(COMMONCPP2_COMPILE_FLAG)
APP_COMPILE = $(CC) $(CXXFLAGS)
OBJ = $(OBJPATH)/CThreadManager.o
#############################################################
.PHONY: all all-before all-after clean clean-custom
all: CThreadManager.o ThreadTest
clean: clean-custom
${RM} $(OBJ) $(BINPATH)/ThreadTest
CThreadManager.o:
$(CC) -o $(OBJPATH)/CThreadManager.o -c $(SRCPATH)/CThreadManager.cpp \
$(INCPATH)/*.h
ThreadTest:
$(APP_COMPILE) $(SRCPATH)/ThreadTest.cpp -o $(BINPATH)/ThreadTest \
$(INCPATH)/*.h \
$(LINKOBJ) \
$(OBJ)
make后,报如下错误:
g++ -o /home/bppf_eas/test/obj/CThreadManager.o -c ./CThreadManager.cpp \
./*.h
g++ -pedantic -Wall -g -O2 ./ThreadTest.cpp -o /home/bppf_eas/test/bin/ThreadTest \
./*.h \
-lpthread \
/home/bppf_eas/test/obj/CThreadManager.o
/home/bppf_eas/test/obj/CThreadManager.o: file not recognized: File format not recognized
collect2: ld 返回 1
make: *** [ThreadTest] 错误 1
------解决方案--------------------版本低了 升级吧 apt-get update
------解决方案--------------------一般都是写隐式编译的, 这样一个一个指定文件容易出问题, 而且还麻烦。
------解决方案--------------------用file命令看看你那个静态库是不是i386的。。。
------解决方案--------------------编译要写 -c