FreeImage编译arm组件

1、 Linux使用的是Makefile.gnu

2、对于make中的这种错误

Source/LibRawLite/./internal/dcraw_common.cpp:2501:3: error: narrowing conversion of ‘-3’ from ‘int’ to char’ inside { } [-Wnarrowing]

在编译文件中添加:

 3、 对于整数转转换的错误

dcraw_common.cpp:4546:3: 错误:在 {} 内将‘128’从‘int’转换为较窄的类型‘signed char’ [-Wnarrowing]

将文件中这部分代码进行修改:

4536   static const signed char *cp, terms[] = {
4537     -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01,
4538     -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01,
4539     -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03,
4540     -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06,
4541     -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04,
4542     -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01,
4543     -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40,
4544     -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11,
4545     -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11,
4546     -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22,
4547     -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44,
4548     -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10,
4549     -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04,
4550     +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40,
4551     +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20,
4552     +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08,
4553     +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20,
4554     +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44,
4555     +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60,
4556     +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80,
4557     +1,-1,+1,+1,0,+1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
4558     +1,+0,+2,+1,0,0x10
4559   }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };

修改成:

4536   static const signed char *cp, terms[] = {
4537     -2,-2,+0,-1,0,(char)0x01, -2,-2,+0,+0,1,(char)0x01, -2,-1,-1,+0,0,(char)0x01,
4538     -2,-1,+0,-1,0,(char)0x02, -2,-1,+0,+0,0,(char)0x03, -2,-1,+0,+1,1,(char)0x01,
4539     -2,+0,+0,-1,0,(char)0x06, -2,+0,+0,+0,1,(char)0x02, -2,+0,+0,+1,0,(char)0x03,
4540     -2,+1,-1,+0,0,(char)0x04, -2,+1,+0,-1,1,(char)0x04, -2,+1,+0,+0,0,(char)0x06,
4541     -2,+1,+0,+1,0,(char)0x02, -2,+2,+0,+0,1,(char)0x04, -2,+2,+0,+1,0,(char)0x04,
4542     -1,-2,-1,+0,0,(char)0x80, -1,-2,+0,-1,0,(char)0x01, -1,-2,+1,-1,0,(char)0x01,
4543     -1,-2,+1,+0,1,(char)0x01, -1,-1,-1,+1,0,(char)0x88, -1,-1,+1,-2,0,(char)0x40,
4544     -1,-1,+1,-1,0,(char)0x22, -1,-1,+1,+0,0,(char)0x33, -1,-1,+1,+1,1,(char)0x11,
4545     -1,+0,-1,+2,0,(char)0x08, -1,+0,+0,-1,0,(char)0x44, -1,+0,+0,+1,0,(char)0x11,
4546     -1,+0,+1,-2,1,(char)0x40, -1,+0,+1,-1,0,(char)0x66, -1,+0,+1,+0,1,(char)0x22,
4547     -1,+0,+1,+1,0,(char)0x33, -1,+0,+1,+2,1,(char)0x10, -1,+1,+1,-1,1,(char)0x44,
4548     -1,+1,+1,+0,0,(char)0x66, -1,+1,+1,+1,0,(char)0x22, -1,+1,+1,+2,0,(char)0x10,
4549     -1,+2,+0,+1,0,(char)0x04, -1,+2,+1,+0,1,(char)0x04, -1,+2,+1,+1,0,(char)0x04,
4550     +0,-2,+0,+0,1,(char)0x80, +0,-1,+0,+1,1,(char)0x88, +0,-1,+1,-2,0,(char)0x40,
4551     +0,-1,+1,+0,0,(char)0x11, +0,-1,+2,-2,0,(char)0x40, +0,-1,+2,-1,0,(char)0x20,
4552     +0,-1,+2,+0,0,(char)0x30, +0,-1,+2,+1,1,(char)0x10, +0,+0,+0,+2,1,(char)0x08,
4553     +0,+0,+2,-2,1,(char)0x40, +0,+0,+2,-1,0,(char)0x60, +0,+0,+2,+0,1,(char)0x20,
4554     +0,+0,+2,+1,0,(char)0x30, +0,+0,+2,+2,1,(char)0x10, +0,+1,+1,+0,0,(char)0x44,
4555     +0,+1,+1,+2,0,(char)0x10, +0,+1,+2,-1,1,(char)0x40, +0,+1,+2,+0,0,(char)0x60,
4556     +0,+1,+2,+1,0,(char)0x20, +0,+1,+2,+2,0,(char)0x10, +1,-2,+1,+0,0,(char)0x80,
4557     +1,-1,+1,+1,0,+1,+0,+1,+2,0,(char)0x08, +1,+0,+2,-1,0,(char)0x40,
4558     +1,+0,+2,+1,0,(char)0x10
4559   }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };

4 对于这个错误

Source/LibRawLite/./internal/dcraw_common.cpp:6940:97: error: call of overloaded ‘powf64(int, int)’ is ambiguous
                     10*(table_buf[iLensData+9]>>2) * powf64(4, (table_buf[iLensData+9] & 0x03)-2);

修改对应位置:4改成4.f

 if (table_buf[iLensData+9] && (fabs(imgdata.lens.makernotes.CurFocal) < 0.1f))
  imgdata.lens.makernotes.CurFocal = 10*(table_buf[iLensData+9]>>2) * powf64(4.f, (table_buf[iLensData+9] & 0x03)-2);

5 对于错误

Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:37:34: error: invalid character ' ' in raw string delimiter
       "shll_s.w         %["#R"],      %["#R"],        9              \n\t"     \
                             ^     
Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:37:48: error: invalid character ' ' in raw string delimiter
       "shll_s.w         %["#R"],      %["#R"],        9              \n\t"     \
                                           ^     
Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:40:34: error: invalid character ' ' in raw string delimiter
       "precrqu_s.qb.ph  %["#R"],      %["#R"],        $zero          \n\t"     \
                             ^     
Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:40:48: error: invalid character ' ' in raw string delimiter
       "precrqu_s.qb.ph  %["#R"],      %["#R"],        $zero          \n\t"     \
                                           ^     
Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:43:34: error: invalid character ' ' in raw string delimiter
       "srl              %["#R"],      %["#R"],        24             \n\t"     \
                             ^     
Source/LibWebP/./src/dsp/dsp.upsampling_mips_dsp_r2.c:43:48: error: invalid character ' ' in raw string delimiter
       "srl              %["#R"],      %["#R"],        24             \n\t"     \

修改这个文件的对应位置:dsp.upsampling_mips_dsp_r2.c 将R改成Red

 Source/LibWebP/./src/dsp/dsp.yuv_mips_dsp_r2.c:57:35: error: unterminated raw string
   "sb               %[temp5],   "#R"(%[dst])

 6 fpic的问题

1-5修改后已经没有语法错误但是无法编译输出,提示:

Source/LibRawLite/./src/libraw_datastream.o: In function `LibRaw_abstract_datastream::LibRaw_abstract_datastream()':
libraw_datastream.cpp:(.text._ZN26LibRaw_abstract_datastreamC2Ev[_ZN26LibRaw_abstract_datastreamC5Ev]+0x8): dangerous relocation: unsupported relocation
/usr/bin/ld: Source/LibRawLite/./src/libraw_datastream.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTV26LibRaw_abstract_datastream' which may bind externally can not be used when making a shared object; recompile with -fPIC
Source/LibRawLite/./src/libraw_datastream.o: In function `LibRaw_abstract_datastream::~LibRaw_abstract_datastream()':
libraw_datastream.cpp:(.text._ZN26LibRaw_abstract_datastreamD2Ev[_ZN26LibRaw_abstract_datastreamD5Ev]+0xc): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
Makefile.gnu:71: recipe for target 'libfreeimage-3.17.0.so' failed
make[1]: *** [libfreeimage-3.17.0.so] Error 1
make[1]: Leaving directory '/FreeImage'
Makefile:23: recipe for target 'default' failed
make: *** [default] Error 2

 makefile增加fpic选项;原始的makefile是只给X86 加了这个选项;下边是完成的makefile.gnu用于arm的:

# Linux makefile for FreeImage

# This file can be generated by ./gensrclist.sh
include Makefile.srcs

# General configuration variables:
DESTDIR ?= /
INCDIR ?= $(DESTDIR)/usr/include
INSTALLDIR ?= $(DESTDIR)/usr/lib

# Converts cr/lf to just lf
DOS2UNIX = dos2unix

LIBRARIES = -lstdc++
CXXFLAGS += -Wno-narrowing

MODULES = $(SRCS:.c=.o)
MODULES := $(MODULES:.cpp=.o)
CFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
# OpenJPEG
CFLAGS += -DOPJ_STATIC
# LibRaw
CFLAGS += -DNO_LCMS
# LibJXR
CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
CFLAGS += $(INCLUDE)
CXXFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
# LibJXR
CXXFLAGS += -D__ANSI__
CXXFLAGS += $(INCLUDE)


CFLAGS += -fPIC
CXXFLAGS += -fPIC

#ifeq ($(shell sh -c 'uname -m 2>/dev/null || echo not'),x86_64)
#    CFLAGS += -fPIC
#    CXXFLAGS += -fPIC
#endif

TARGET  = freeimage
STATICLIB = lib$(TARGET).a
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
LIBNAME    = lib$(TARGET).so
VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
HEADER = Source/FreeImage.h



default: all

all: dist

dist: FreeImage
    mkdir -p Dist
    cp *.a Dist/
    cp *.so Dist/
    cp Source/FreeImage.h Dist/

dos2unix:
    @$(DOS2UNIX) $(SRCS) $(INCLS)

FreeImage: $(STATICLIB) $(SHAREDLIB)

.c.o:
    $(CC) $(CFLAGS) -c $< -o $@

.cpp.o:
    $(CXX) $(CXXFLAGS) -c $< -o $@

$(STATICLIB): $(MODULES)
    $(AR) r $@ $(MODULES)

$(SHAREDLIB): $(MODULES)
    $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)

install:
    install -d $(INCDIR) $(INSTALLDIR)
    install -m 644 -o root -g root $(HEADER) $(INCDIR)
    install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
    install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
    ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
    ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)    
#    ldconfig

clean:
    rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)

 

posted on 2024-08-28 16:48  邗影  阅读(7)  评论(0编辑  收藏  举报

导航