0

I have followed a tutorial on Wii Homebrew Development for displaying better fonts. And there seems to be some issues with the library I am using. FT_Library and FT_Face are not declared. The library I am using is ftImage, do I have to setup FT_Library? If so how is it done on Windows?

My makefile

#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

include $(DEVKITPPC)/wii_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
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET      :=  $(notdir $(CURDIR))
BUILD       :=  build
SOURCES     :=  source
DATA        :=  data  
INCLUDES    :=

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS  = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS    =   $(CFLAGS)

LDFLAGS =   -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS    :=  -lwiiuse -lbte -logc -lm -lfreetype -lftimage

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

#---------------------------------------------------------------------------------
# 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 VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
                    $(foreach dir,$(DATA),$(CURDIR)/$(dir))

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

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
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_BIN   :=  $(addsuffix .o,$(BINFILES))
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)

export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE  :=  $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
                    $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
                    -I$(CURDIR)/$(BUILD) \
                    -I$(LIBOGC_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
                    -L$(LIBOGC_LIB)

export OUTPUT   :=  $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean

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

#---------------------------------------------------------------------------------
clean:
    @echo clean ...
    @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol

#---------------------------------------------------------------------------------
run:
    wiiload $(TARGET).dol


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

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

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)

$(OFILES_SOURCES) : $(HFILES)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o %_jpg.h :   %.jpg
#---------------------------------------------------------------------------------
    @echo $(notdir $<)
    $(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .ttf extension
#---------------------------------------------------------------------------------
%.ttf.o : %.ttf
#---------------------------------------------------------------------------------
    @echo $(notdir $<) 
    $(bin2o)

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

My main code (From tutorial)

#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <iostream> 
#include "libs/ftImage.h" //The ftimage library
#include "fontawesome_webfont_ttf.h"

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

    // Initialise the video system
    VIDEO_Init();

    // This function initialises the attached controllers
    WPAD_Init();

    // Obtain the preferred video mode from the system
    // This will correspond to the settings in the Wii menu
    rmode = VIDEO_GetPreferredMode(NULL);

    // Allocate memory for the display in the uncached region
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

    // Initialise the console, required for printf
    console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

    // Set up the video registers with the chosen mode
    VIDEO_Configure(rmode);

    // Tell the video hardware where our display memory is
    VIDEO_SetNextFramebuffer(xfb);

    // Make the display visible
    VIDEO_SetBlack(FALSE);

    // Flush the video register changes to the hardware
    VIDEO_Flush();

    // Wait for Video setup to complete
    VIDEO_WaitVSync();
    if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();


    // The console understands VT terminal escape codes
    // This positions the cursor on row 2, column 0
    // we can use variables for this with format codes too
    // e.g. printf ("\x1b[%d;%dH", row, column );

    ftImage print(640, 480); //This will store the string of text we print
    Sprite Text; //This Sprite will be used to render the ftImage member print

    print.setFont(fontawesome_webfont_ttf, fontawesome_webfont_ttf_size);//Set the font we are using
    print.setSize(32);//Set the size of the font (should be a multiple of 4)
    print.setColor(Color(255,40,40));//Set the color of the font in RGB format
    Text.SetPosition(100, 50);//Set the position of the starting point of the text we will print
    Text.SetImage(&print);//Append print as the image stored by Text

    print.printf(" Hellow World!\n");//Set the string of text to be rendered (escape characters can be use to render more than one line)
    print.flush();//Tell the computer that the string of text is ready
    Text.Draw();//Render the text
    print.clear();//Clear the stored string of text
    print.reset();//Bring us back to the render starting point (defined by Text.SetPosisition())

    while(1) {

        // Call WPAD_ScanPads each loop, this reads the latest controller states
        WPAD_ScanPads();

        // WPAD_ButtonsDown tells us which buttons were pressed in this loop
        // this is a "one shot" state which will not fire again until the button has been released
        u32 pressed = WPAD_ButtonsDown(0);

        // We return to the launcher application via exit
        if ( pressed & WPAD_BUTTON_HOME ) exit(0);

        // Wait for the next frame
        VIDEO_WaitVSync();
    }

    return 0;
}

I dont think I can post the library code legally so I will say the library name

ftImage

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
  • Looks like you're new here. Welcome! People are reluctant to help if you don't show what you have tried. Writing about what you've tried and why it isn't working will also make it much easier for the volunteers here to intelligently comment on your issue. – zetavolt Jul 18 '17 at 22:57
  • My code isnt the issue. Its the library, the error is coming from the library. – Lifeidio Online Jul 18 '17 at 23:01
  • Imagine you are someone reading your own post. You read something like "FT_Library isn't declared". To someone who has been programming for awhile, that could mean dozens of different things. Is this a linker issue? Are you statically compiling? Does that mean that you are trying to include FT_FACE? What language? Is this one of those really basic issues that is covered in every book on programming or are you dealing with a more complex issue? There is no way for someone reading your post to know more about these kind of questions without you posting more information. – zetavolt Jul 18 '17 at 23:17
  • Oh okay... well I will post my makefile, and I guess the library code. – Lifeidio Online Jul 19 '17 at 00:00
  • I have been a C++ programmer for sometime.. but my specialties are library creation, Windows programming, and Web CGI, Wii Homebrew is completely new to me. – Lifeidio Online Jul 19 '17 at 00:04
  • So Idk anything about this library whatsoever. I mean I have all the libs they requested linked... I just dont know what could be wrong. – Lifeidio Online Jul 19 '17 at 00:23
  • You still haven't posted the exact error you are receiving. It seems like you are building in MinGW/Cygwin or a windows autotools build. If your problem is occurring at runtime, have you configured your dynamic linker's runtime bindings (e.g `ldconfig` if you are using Cygwin or your DLL search path if you are asking for a shared object via `LoadLibraryEx()`)? If this is a compile-time problem, you can see you are using `"ftImage.h"` instead of ``, which I assume you've accounted for in checking your linker's file inclusions? – zetavolt Jul 19 '17 at 00:33
  • ftImage is declared. But in ftImage there is a object being used named FT_Library.. which is throwing an error from the library saying its not declared. – Lifeidio Online Jul 19 '17 at 00:40
  • It's hard to know exactly what the issue is without the *exact* error message, but it sounds like a standard library linkage issue. You mentioned you were pretty competent with C++ so it sounds like building the appropriate library (`ftImage`) and ensuring that your compiler or linker searches for that named library **AND** has access to it's object code / header (whichever is appropriate). – zetavolt Jul 19 '17 at 00:47
  • I know C++, but I never used the library. I did not write it either. First time ever using it, so I dont really know how to set it up. – Lifeidio Online Jul 19 '17 at 00:49
  • FT_Library seems to be something else. (Free Type) not ftImage – Lifeidio Online Jul 19 '17 at 00:50
  • Im guessing that ftImage was a sub class for C++ users, as (as far as I am aware) Free Type is C, and I dont know C very well. – Lifeidio Online Jul 19 '17 at 00:50
  • Ok, basically you do the following: Make sure you have `ftImage` (the library) built and installed on your system. Typically you open up a command line / terminal inside of where `ftImage` is and then run `./configure ; make ; make install` (if you are using Cygwin). After that, the library will have files with `.so` and `.h` extensions, make sure you add the `.h` (headers) to `INCLUDE` in your makefile as it already looks like your makefile is sourcing the named directory. Typically the `make install` step will move the `.so` files to the appropriate folder where your system can use them. – zetavolt Jul 19 '17 at 00:54
  • The ftImage library was already made no? Also I am not using Cygwin.. i am using MingW – Lifeidio Online Jul 19 '17 at 01:05
  • *"Built"* or *"Build"* in programming means *"to compile"* - the step that takes all of the resources that a program uses and transforms and packages them into a file or set of files that the computer can understand. It may be the most profitable use of your time to download & read a book like [K&R's C Programming Language](https://archive.org/details/TheCProgrammingLanguageFirstEdition) – zetavolt Jul 19 '17 at 01:08
  • It was pre-compiled I know what built means. I got the pre-compiled version. – Lifeidio Online Jul 19 '17 at 02:02

0 Answers0