gcc makefile生成的静态库是空的,为什么?

时间:2015-07-28 15:24:41

标签: makefile static-libraries .a

我试图创建一个简单的静态库" mylib.a"使用makefile和gcc。 目标文件在源目录中创建,库" mylib.a"也是创建但它是空的(但文件显示一些kb)。这是我的makefile:

CPPUTEST_HOME = C:\UTest
CPP_PLATFORM = Gcc

TARGET= mylib.a

CPP    = g++
FLAGS        = -std=gnu99 -Iinclude
CFLAGS       = -fPIC -pedantic -Wall -Wextra -march=native -ggdb3
DEBUGFLAGS   = -O0 -D _DEBUG
RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program
LDFLAGS = -shared  # linking flags

SOURCES = \
    $(CPPUTEST_HOME)/src/CppUTest/file1.cpp \
    $(CPPUTEST_HOME)/src/CppUTest/file2.cpp \
    $(CPPUTEST_HOME)/src/CppUTest/file3.cpp \
    $(CPPUTEST_HOME)/src/CppUTest/file4 

OBJECTS = $(SOURCES:.cpp=.o)

$(TARGET): $(OBJECTS) 
    $(CPP) $(FLAGS) $(CFLAGS) $(DEBUGFLAGS) $(INCLUDES) -o $(TARGET)       $(OBJECTS)

  clean:
  rm $(OBJECTS) 

这有什么问题?我也是关于makefile的新手......

1 个答案:

答案 0 :(得分:0)

So, as result I get: $(CPPUTEST_HOME)/src/CppUTest/file1.o , $(CPPUTEST_HOME)/src/CppUTest/file2.o, $(CPPUTEST_HOME)/src/CppUTest/file3.o, $(CPPUTEST_HOME)/src/CppUTest/file4.o,

and on top of the directory ((CPPUTEST_HOME)/src)) I get the "mylib.a" file. This lib is empty. But if I look into the properties, the "mylib.a" file has about 60kb....