Compilation error (sf2d/sfil/sftd)

Discussion in '3DS - Homebrew Development and Emulators' started by Coc4tm, Oct 9, 2016.

  1. Coc4tm
    OP

    Coc4tm WIP Nintendo hacker.

    Member
    355
    251
    Feb 12, 2016
    France
    fw.img
    Hi ! I have a compilation error with sf2dlib , sfilib and sftdlib.
    I use last version of devkitarm , ctrulib , portlibs , etc...
    Here is what i got :
    cow-pc EnfinCaMarche # make
    linking sftd_sample.elf
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(sfnt.o): In function `error_callback':
    sfnt.c:(.text+0x47fc): undefined reference to `png_get_error_ptr'
    sfnt.c:(.text+0x4814): undefined reference to `png_set_longjmp_fn'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(sfnt.o): In function `Load_SBit_Png.isra.16':
    sfnt.c:(.text+0x6af4): undefined reference to `png_create_read_struct'
    sfnt.c:(.text+0x6b08): undefined reference to `png_create_info_struct'
    sfnt.c:(.text+0x6b28): undefined reference to `png_set_longjmp_fn'
    sfnt.c:(.text+0x6b4c): undefined reference to `png_destroy_read_struct'
    sfnt.c:(.text+0x6b70): undefined reference to `png_set_read_fn'
    sfnt.c:(.text+0x6b7c): undefined reference to `png_read_info'
    sfnt.c:(.text+0x6bac): undefined reference to `png_get_IHDR'
    sfnt.c:(.text+0x6c34): undefined reference to `png_destroy_read_struct'
    sfnt.c:(.text+0x6c78): undefined reference to `png_set_palette_to_rgb'
    sfnt.c:(.text+0x6c8c): undefined reference to `png_set_expand_gray_1_2_4_to_8'
    sfnt.c:(.text+0x6c9c): undefined reference to `png_get_valid'
    sfnt.c:(.text+0x6cd8): undefined reference to `png_set_interlace_handling'
    sfnt.c:(.text+0x6ce8): undefined reference to `png_set_filler'
    sfnt.c:(.text+0x6cf4): undefined reference to `png_read_update_info'
    sfnt.c:(.text+0x6d2c): undefined reference to `png_get_IHDR'
    sfnt.c:(.text+0x6d5c): undefined reference to `png_set_read_user_transform_fn'
    sfnt.c:(.text+0x6de4): undefined reference to `png_read_image'
    sfnt.c:(.text+0x6dfc): undefined reference to `png_read_end'
    sfnt.c:(.text+0x6e08): undefined reference to `png_set_gray_to_rgb'
    sfnt.c:(.text+0x6e14): undefined reference to `png_set_packing'
    sfnt.c:(.text+0x6e20): undefined reference to `png_set_tRNS_to_alpha'
    sfnt.c:(.text+0x6e48): undefined reference to `png_set_strip_16'
    sfnt.c:(.text+0x6e58): undefined reference to `png_set_read_user_transform_fn'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(sfnt.o): In function `read_data_from_FT_Stream':
    sfnt.c:(.text+0x6f2c): undefined reference to `png_get_io_ptr'
    sfnt.c:(.text+0x6f64): undefined reference to `png_get_error_ptr'
    sfnt.c:(.text+0x6f78): undefined reference to `png_error'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_stream_close':
    ftgzip.c:(.text+0x40): undefined reference to `inflateEnd'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_file_fill_output':
    ftgzip.c:(.text+0x144): undefined reference to `inflate'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(ftgzip.o): In function `ft_gzip_file_io':
    ftgzip.c:(.text+0x2cc): undefined reference to `inflateReset'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(ftgzip.o): In function `FT_Stream_OpenGzip':
    ftgzip.c:(.text+0x5bc): undefined reference to `inflateInit2_'
    ftgzip.c:(.text+0x778): undefined reference to `inflateReset'
    ftgzip.c:(.text+0x7b4): undefined reference to `inflateEnd'
    /opt/devkitpro/portlibs/armv6k/lib/libfreetype.a(ftgzip.o): In function `FT_Gzip_Uncompress':
    ftgzip.c:(.text+0x910): undefined reference to `inflateInit2_'
    ftgzip.c:(.text+0x938): undefined reference to `inflate'
    ftgzip.c:(.text+0x94c): undefined reference to `inflateEnd'
    ftgzip.c:(.text+0x96c): undefined reference to `inflateEnd'
    collect2: error: ld returned 1 exit status
    /opt/devkitpro/devkitARM/3ds_rules:39 : la recette pour la cible « /home/cow/Bureau/Zbeub/EnfinCaMarche/sftd_sample.elf » a échouée
    make[1]: *** [/home/cow/Bureau/Zbeub/EnfinCaMarche/sftd_sample.elf] Erreur 1
    Makefile:130 : la recette pour la cible « build » a échouée
    make: *** [build] Erreur 2
    And this is my makefile :
    #---------------------------------------------------------------------------------
    .SUFFIXES:
    #---------------------------------------------------------------------------------

    ifeq ($(strip $(DEVKITARM)),)
    $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
    endif

    TOPDIR ?= $(CURDIR)
    include $(DEVKITARM)/3ds_rules

    #---------------------------------------------------------------------------------
    # TARGET is the name of the output
    # BUILD is the directory where object files & intermediate files will be placed
    # SOURCES is a list of directories containing source code
    # DATA is a list of directories containing data files
    # INCLUDES is a list of directories containing header files
    #
    # NO_SMDH: if set to anything, no SMDH file is generated.
    # APP_TITLE is the name of the app stored in the SMDH file (Optional)
    # APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
    # APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
    # ICON is the filename of the icon (.png), relative to the project folder.
    # If not set, it attempts to use one of the following (in this order):
    # - <Project name>.png
    # - icon.png
    # - <libctru folder>/default_icon.png
    #---------------------------------------------------------------------------------
    TARGET := sftd_sample
    BUILD := build
    SOURCES := source
    DATA := data
    INCLUDES := include

    APP_TITLE := SFFTLIB sample
    APP_DESCRIPTION := SFFTLIB sample
    APP_AUTHOR := xerpi

    #---------------------------------------------------------------------------------
    # options for code generation
    #---------------------------------------------------------------------------------
    ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft

    CFLAGS := -g -Wall -O2 -mword-relocations \
    -fomit-frame-pointer -ffunction-sections -ffast-math\
    $(ARCH)

    CFLAGS += $(INCLUDE) -DARM11 -D_3DS

    CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

    ASFLAGS := -g $(ARCH)
    LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

    LIBS := -lsfil -lpng -ljpeg -lz -lsf2d -lcitro3d -lctru -lm -lsftd -lfreetype

    #---------------------------------------------------------------------------------
    # list of directories containing libraries, this must be the top level containing
    # include and lib
    #---------------------------------------------------------------------------------
    LIBDIRS := $(CTRULIB) $(PORTLIBS)


    #---------------------------------------------------------------------------------
    # no real need to edit anything past this point unless you need to add additional
    # rules for different file extensions
    #---------------------------------------------------------------------------------
    ifneq ($(BUILD),$(notdir $(CURDIR)))
    #---------------------------------------------------------------------------------

    export OUTPUT := $(CURDIR)/$(TARGET)
    export TOPDIR := $(CURDIR)

    export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
    $(foreach dir,$(DATA),$(CURDIR)/$(dir))

    export DEPSDIR := $(CURDIR)/$(BUILD)

    CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
    CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
    SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
    BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

    #---------------------------------------------------------------------------------
    # use CXX for linking C++ projects, CC for standard C
    #---------------------------------------------------------------------------------
    ifeq ($(strip $(CPPFILES)),)
    #---------------------------------------------------------------------------------
    export LD := $(CC)
    #---------------------------------------------------------------------------------
    else
    #---------------------------------------------------------------------------------
    export LD := $(CXX)
    #---------------------------------------------------------------------------------
    endif
    #---------------------------------------------------------------------------------

    export OFILES := $(addsuffix .o,$(BINFILES)) \
    $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

    export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
    $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
    -I$(CURDIR)/$(BUILD)

    export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

    ifeq ($(strip $(ICON)),)
    icons := $(wildcard *.png)
    ifneq (,$(findstring $(TARGET).png,$(icons)))
    export APP_ICON := $(TOPDIR)/$(TARGET).png
    else
    ifneq (,$(findstring icon.png,$(icons)))
    export APP_ICON := $(TOPDIR)/icon.png
    endif
    endif
    else
    export APP_ICON := $(TOPDIR)/$(ICON)
    endif

    ifeq ($(strip $(NO_SMDH)),)
    export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
    endif

    .PHONY: $(BUILD) clean all

    #---------------------------------------------------------------------------------
    all: $(BUILD)

    $(BUILD):
    @[ -d $@ ] || mkdir -p $@
    @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

    #---------------------------------------------------------------------------------
    clean:
    @Echo clean ...
    @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(TARGET)-strip.elf $(TARGET).cia $(TARGET).3ds
    #---------------------------------------------------------------------------------
    $(TARGET)-strip.elf: $(BUILD)
    @$(STRIP) $(TARGET).elf -o $(TARGET)-strip.elf
    #---------------------------------------------------------------------------------
    cci: $(TARGET)-strip.elf
    @makerom -f cci -rsf resources/$(TARGET).rsf -target d -exefslogo -elf $(TARGET)-strip.elf -o $(TARGET).3ds
    @Echo "built ... sf2d_sample.3ds"
    #---------------------------------------------------------------------------------
    cia: $(TARGET)-strip.elf
    @makerom -f cia -o $(TARGET).cia -elf $(TARGET)-strip.elf -rsf resources/$(TARGET).rsf -exefslogo -target t
    @Echo "built ... sf2d_sample.cia"
    #---------------------------------------------------------------------------------
    send: $(BUILD)
    @3dslink $(TARGET).3dsx
    #---------------------------------------------------------------------------------
    run: $(BUILD)
    @Citra $(TARGET).3dsx

    #---------------------------------------------------------------------------------
    else

    DEPENDS := $(OFILES:.o=.d)

    #---------------------------------------------------------------------------------
    # main targets
    #---------------------------------------------------------------------------------
    ifeq ($(strip $(NO_SMDH)),)
    $(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
    else
    $(OUTPUT).3dsx : $(OUTPUT).elf
    endif

    $(OUTPUT).elf : $(OFILES)

    #---------------------------------------------------------------------------------
    # you need a rule like this for each extension you use as binary data
    #---------------------------------------------------------------------------------
    %.bin.o : %.bin
    #---------------------------------------------------------------------------------
    @Echo $(notdir $<)
    @$(bin2o)

    #---------------------------------------------------------------------------------
    %.ttf.o : %.ttf
    #---------------------------------------------------------------------------------
    @Echo $(notdir $<)
    @$(bin2o)

    # WARNING: This is not the right way to do this! TODO: Do it right!
    #---------------------------------------------------------------------------------
    %.jpeg.o: %.jpeg
    #---------------------------------------------------------------------------------
    @Echo $(notdir $<)
    @$(bin2o)

    #---------------------------------------------------------------------------------
    %.png.o : %.png
    #---------------------------------------------------------------------------------
    @Echo $(notdir $<)
    @$(bin2o)

    # WARNING: This is not the right way to do this! TODO: Do it right!
    #---------------------------------------------------------------------------------
    %.vsh.o : %.vsh
    #---------------------------------------------------------------------------------
    @Echo $(notdir $<)
    @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
    @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
    @Echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
    @Echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
    @Echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
    @rm ../$(notdir $<).shbin

    -include $(DEPENDS)

    #---------------------------------------------------------------------------------------
    endif
    #---------------------------------------------------------------------------------------
    Is there someone for help me ?
     
  2. cheuble

    cheuble Marieism™

    Member
    714
    1,342
    Feb 6, 2016
    France
    Somewhere
    It looks like the error comes from this line:
    Try change the orders and see if it works.
     
  3. Omegadrien

    Omegadrien GBAtemp Advanced Maniac

    Member
    1,713
    530
    Nov 4, 2015
    France
    Pokéland
    Do you use https://github.com/BernardoGiordano/GUI-Template-for-3DS-homebrews ?
    Because i have the same issue if i use the sfil_load_JPEG_file function....
     
  4. Coc4tm
    OP

    Coc4tm WIP Nintendo hacker.

    Member
    355
    251
    Feb 12, 2016
    France
    fw.img
    Not anymore...
    This doesn't work...
     
  5. cheuble

    cheuble Marieism™

    Member
    714
    1,342
    Feb 6, 2016
    France
    Somewhere
    Can you send me your project as a zip?
     
  6. Coc4tm
    OP

    Coc4tm WIP Nintendo hacker.

    Member
    355
    251
    Feb 12, 2016
    France
    fw.img
    Ok
     

    Attached Files:

  7. cheuble

    cheuble Marieism™

    Member
    714
    1,342
    Feb 6, 2016
    France
    Somewhere
    Fixed, replace with this line
    Code:
    LIBS   :=  -lsftd -lsf2d -lsfil -lctru -lcitro3d -lfreetype -lpng -ljpeg -lz -lm
     
    Omegadrien likes this.
  8. Coc4tm
    OP

    Coc4tm WIP Nintendo hacker.

    Member
    355
    251
    Feb 12, 2016
    France
    fw.img
    Works ! Thanks ! :)
     
  9. cheuble

    cheuble Marieism™

    Member
    714
    1,342
    Feb 6, 2016
    France
    Somewhere
    Those kind of errors happens frequently, it's always an error in the makefile
     
  10. bayleef

    bayleef Advanced Member

    Newcomer
    83
    147
    Sep 15, 2015
    Gambia, The
    No. You had a linking error.
     
  11. Coc4tm
    OP

    Coc4tm WIP Nintendo hacker.

    Member
    355
    251
    Feb 12, 2016
    France
    fw.img