海思osd+freetype+SDL+SDL_ttf编译成功后,Makefile的编写

    请先移步我的上一篇转载博文http://blog.csdn.net/qq_26671365/article/details/78974661,这里先感谢一下博文的原创者,使我受益匪浅。

这里假设你已经装好freetype,SDL还有SDL_ttf

 arm-hisiv400-linux-gcc test.c`sdl-config --cflags --libs`-I/opt/sdl_lib/include-I/opt/sdl_lib/include/SDL-L/opt/sdl_lib/lib-lSDL-lSDL_ttf-Wl,-rpath-o test

上面的命令是编译SDL 测试文件的shell语句,经测试可用。但是最后我们的目的还是要在海思的demo或者自己编写的app中使用SDL,我把以上语句单独

放在Makefile中可以编译SDL测试demo。那么怎么把这条语句加入海思的Makefile中,以便我们方便在海思的demo中使用SDL呢?

先看一看海思的Makefile吧

# Hisilicon Hi3516 sample Makefile


include ../Makefile.param
#ifeq ($(SAMPLE_PARAM_FILE), )
#     SAMPLE_PARAM_FILE:=../Makefile.param
#     include $(SAMPLE_PARAM_FILE)
#endif


# target source
SRC  := $(wildcard *.c) 
OBJ  := $(SRC:%.c=%.o)


TARGET := $(OBJ:%.o=%)
.PHONY : clean all


all: $(TARGET)


MPI_LIBS := $(REL_LIB)/libmpi.a


$(TARGET):%:%.o $(COMM_OBJ)
$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) $(SENSOR_LIBS)


clean:
@rm -f $(TARGET)
@rm -f $(OBJ)
@rm -f $(COMM_OBJ)


cleanstream:
@rm -f *.h264
@rm -f *.jpg
@rm -f *.mjp
@rm -f *.mp4

核心是这一句,$(TARGET):%:%.o $(COMM_OBJ)
$(CC) $(CFLAGS) -lpthread -lm -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) $(SENSOR_LIBS)

我有试过将SDL的编译语句加入这句话中,但是行不通。

现在来稍微分析下这一段Makefile语句。

$(TARGET):%:%.o $(COMM_OBJ)的意思是$(TARGET)的生成依赖于所有的.o文件和COMM文件夹下面的.obj文件

这个Makefile包含了其他目录的Makefile.param,总共包含了两层。查看.param文件可以看到

$(CC)的值为arm-hisiv500-linux-gcc

$(CFLAGS)包含了所有的编译选项、包含文件路径、链接动态库,静态库路径,其中也包含了-lpthread和-lm,所以把后面的-lpthread与-lm去掉也没问题,这个应该是

海思开发人员的一点点疏漏。

$(MPI_LIBS) $(AUDIO_LIBA) $(SENSOR_LIBS这三项是具体的附加依赖库库名称

我们再看一下SDL的编译语句

arm-hisiv400-linux-gcc test.c`sdl-config --cflags --libs`

-I/opt/sdl_lib/include-I/opt/sdl_lib/include/SDL-L/opt/sdl_lib/lib-lSDL-lSDL_ttf-Wl,-rpath-o test

$(CC)=arm-hisiv400-linux-gcc,这个不用管他了

`sdl-config --cflags --libs`加在$(CFLAGS)中(在.param文件中加)

-I/opt/sdl_lib/include-I/opt/sdl_lib/include/SDL也加在$(CFLAGS)中(在.param文件中相应位置加)

-lSDL-lSDL_ttf-Wl,-rpath也加在$(CFLAGS)中

-L/opt/sdl_lib/lib要稍微注意下,修改后变成这样(也是在Makefile.param中修改)

export SDL_LIBA ?= /opt/sdl_lib/lib/libfreetype.a\
/opt/sdl_lib/lib/libSDL.a\
/opt/sdl_lib/lib/libSDL_ttf.a
export SDL_LIBS ?= /opt/sdl_lib/lib/libfreetype.so\
  /opt/sdl_lib/lib/libSDL.so\
  /opt/sdl_lib/lib/libSDL_ttf.so

最终这一句Makefile语句修改成

$(TARGET):%:%.o $(COMM_OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(MPI_LIBS) $(AUDIO_LIBA) $(SENSOR_LIBS) $(SDL_LIBA) $(SDL_LIBS)

其他的地方不用改。

最后给大家看一下展开后的编译语句

arm-hisiv400-linux-gcc -Wall -g `sdl-config --cflags --libs` -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common -I/opt/sdl_lib/include -I/opt/sdl_lib/include/SDL -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/include -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/component/acodec -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/extdrv/tw2865 -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/extdrv/tlv320aic31 -I/home/ach/Hi3516A_SDK_V2.0.7.0/mpp/extdrv/ak7756en -Dhi3516a -DHICHIP=0x3516A100 -DSENSOR_TYPE=PANASONIC_MN34220_SUBLVDS_720P_120FPS -DHI_RELEASE -DHI_XXXX -lpthread -lm -ldl -lSDL -lSDL_ttf -Wl,-rpath -DISP_V2 -DHI_ACODEC_TYPE_INNER -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -ffunction-sections -mno-unaligned-access -fno-aggressive-loop-optimizations -ldl -o appmain appmain.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_vpss.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_sys.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_isp.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_audio.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/loadbmp.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_ive.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_vo.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_venc.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_vi.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/sample/achcamapp/../common/sample_comm_vda.o /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libmpi.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libtde.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libVoiceEngine.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libupvqe.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libdnvqe.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libisp.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/libsns_mn34220.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_cmoscfg.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_iniparser.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_hiae.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_hiawb.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_hiaf.a /home/ach/Hi3516A_SDK_V2.0.7.0/mpp/lib/lib_hidefog.a /opt/sdl_lib/lib/libfreetype.a /opt/sdl_lib/lib/libSDL.a /opt/sdl_lib/lib/libSDL_ttf.a /opt/sdl_lib/lib/libfreetype.so /opt/sdl_lib/lib/libSDL.so /opt/sdl_lib/lib/libSDL_ttf.so

如有其他问题可以私信本人

你可能感兴趣的:(嵌入式,图像&视频,linux)